[Haskell-beginners] Implementing Read
Sean Perry
shaleh at speakeasy.net
Mon Sep 12 00:21:00 CEST 2011
I see this has been answered, but since someone else may be learning too I thought I would share.
I have always used deriving for Read so I was unsure. This post gave me the push to go hunt it down. A very quick grep for "instance Read" in the ghc lib sources and I found:
instance Read Int64 where
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
In the Int.hs source. The other ints are similar. So like Daniel I ended up with a definition based on reads once I experimented quickly.
More information about the Beginners
mailing list