[Haskell-cafe] Reading showables

Miguel Mitrofanov miguelimo38 at yandex.ru
Sun Dec 7 09:58:51 EST 2008


Given two different types T1 and T2, it's possible to have two  
different results of

 > let {x :: T1; x = read s} in show x

and

 > let {x :: T2; x = read s} in show x

so that neither of two "read"s fails. For example

 > let {x :: Int; x = read "1000000000000"} in show x

produces the answer "-727379968".

BTW, I'd love to be able to give default instances locally, so that  
something like

 > main = withdef Read Int {putStrLn $ show $ read "1000000000000"}

would typecheck successfully.

On 7 Dec 2008, at 16:11, John Ky wrote:

> Hi,
>
> Is there a way to read Showables?
>
> main = do
>     putStrLn $ show $ read
>
> Thanks
>
> -John
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list