This will be easy to implement with servant. It's also very efficient,
and fairly future-proof. Eg, could add another frame with other data.
This does make it a bit harder to use this protocol, but netstrings
probably take about 5 minutes to implement? Let's see...
import Text.Read
import Data.List
toNetString :: String -> String
toNetString s = show (length s) ++ ":" ++ s ++ ","
nextNetString :: String -> Maybe (String, String)
nextNetString s = case break (== ':') s of
([], _) -> Nothing
(sn, rest) -> do
n <- readMaybe sn
let (v, rest') = splitAt n (drop 1 rest)
return (v, drop 1 rest')
Ok, well, that took about 10 minutes ;-)
|
||
|---|---|---|
| .. | ||
| adjusted_branches | ||
| assistant | ||
| balanced_preferred_content | ||
| encryption | ||
| exporting_trees_to_special_remotes | ||
| external_backend_protocol | ||
| external_special_remote_protocol | ||
| git-remote-daemon | ||
| iabackup | ||
| metadata | ||
| new_repo_versions | ||
| p2p_protocol | ||
| p2p_protocol_over_http | ||
| requests_routing | ||
| adjusted_branches.mdwn | ||
| assistant.mdwn | ||
| balanced_preferred_content.mdwn | ||
| caching_database.mdwn | ||
| encryption.mdwn | ||
| exporting_trees_to_special_remotes.mdwn | ||
| external_backend_protocol.mdwn | ||
| external_special_remote_protocol.mdwn | ||
| gcrypt.mdwn | ||
| git-remote-daemon.mdwn | ||
| iabackup.mdwn | ||
| importing_trees_from_special_remotes.mdwn | ||
| metadata.mdwn | ||
| new_repo_versions.mdwn | ||
| p2p_protocol.mdwn | ||
| p2p_protocol_over_http.mdwn | ||
| passthrough_proxy.mdwn | ||
| preferred_content.mdwn | ||
| requests_routing.mdwn | ||
| roadmap.mdwn | ||