[Haskell-beginners] Data.Text to Int?
Emmanuel Touzery
etouzery at gmail.com
Fri Dec 14 15:57:21 CET 2012
Hello,
I expected "read" to work directly on a Data.Text because Data.Text
has an instance of the Read class, but it seems to fail:
---------
import Data.Text
main = do
let a = pack "1"
let b = read a :: Int
putStrLn "parsed OK"
---------
test.hs:5:22:
Couldn't match expected type `String' with actual type `Text'
In the first argument of `read', namely `a'
In the expression: read a :: Int
In an equation for `b': b = read a :: Int
Sure I can do"read (unpack a) :: Int" but there must be a way to do it
directly?
Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121214/b0902305/attachment.htm>
More information about the Beginners
mailing list