[Haskell-cafe] Why so many strings in Network.URI, System.Posix and similar libraries?

Jason Dusek jason.dusek at gmail.com
Sun Mar 11 04:24:55 CET 2012


The content of URIs is defined in terms of octets in the RFC,
and all Posix interfaces are byte streams and C strings, not
character strings. Yet in Haskell, we find these objects exposed
with String interfaces:

> :info Network.URI.URI
data URI
  = URI {uriScheme :: String,
         uriAuthority :: Maybe URIAuth,
         uriPath :: String,
         uriQuery :: String,
         uriFragment :: String}
        -- Defined in Network.URI

> :info System.Posix.Env.getEnvironment
System.Posix.Env.getEnvironment :: IO [(String, String)]
        -- Defined in System.Posix.Env

But there is no law that environment variables must be made of
characters:

 :; export x=$'\xFF' ; echo -n $x | xxd -p
  ff
 :; locale
  LANG="en_US.UTF-8"

That the relationship between bytes and characters can be
confusing, both in working with UNIX and in dealing with web
protocols, is undeniable -- but it seems unwise to limit the
options available to Haskell programmers in dealing with these
systems.

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B



More information about the Haskell-Cafe mailing list