[Haskell] ANN: data-textual: Human-friendly textual representations

Mikhail Vorozhtsov mikhail.vorozhtsov at gmail.com
Wed Apr 24 08:18:51 CEST 2013


Hello lists,

I'm pleased to announce the first release of data-textual[1], a library 
that provides human-friendly counterparts (called Printable/Textual) of 
the compiler-friendly Show/Read type classes. The library is intended to 
be used for printing and parsing of non-compound and non-polymorphic 
compound data (e.g. numbers, network and hardware addresses, date/time, 
etc).

A quick example (vs network-ip[2] library):

λ> import Data.Maybe (fromJust)
λ> import Data.Textual
λ> import Network.IP.Addr

λ> let x = fromString "[dead::b:e:e:f]:123" :: Maybe Inet6Addr
λ> x
Just (InetAddr {inetHost = ip6FromWords 0xdead 0x0 0x0 0x0 0xb 0xe 0xe 
0xf, inetPort = 123})
λ> toString (fromJust x)
"[dead::b:e:e:f]:123"

λ> let y = fromStringAs aNet4Addr "192.168.100.1/24"
λ> y
Just (netAddr (ip4FromOctets 192 168 100 1) 24)
λ> toText (netPrefix $ fromJust y)
"192.168.100.0"

[1] http://hackage.haskell.org/package/data-textual
[2] http://hackage.haskell.org/package/network-ip



More information about the Haskell mailing list