by CJefferson · 13y ago · 0 comments
> map reverse
No instance for (GHC.Show.Show ([[a0]] -> [[a0]]))
arising from a use of `M1690418375.show_M1690418375'
Possible fix:
add an instance declaration for (GHC.Show.Show ([[a0]] -> [[a0]]))
Hmm.... > :t map reverse
:: [[a]] -> [[a]]
> show (map reverse)
No instance for (GHC.Show.Show ([[a0]] -> [[a0]]))
You can't show functions. Pass an argument: > map reverse ["test","this"]
=> ["tset","siht"]> let f = map reverse
> f [[1,2,3], [6,7,8]]
EDIT: scratch the "let" example (thanks nandemo), tryhaskell.org doesn't support that. my bad!
Note that in "let t=bar in foo" the scope of t is restricted to foo, so the example above still doesn't work.
[1] http://www.reddit.com/r/haskell/comments/b58rk/try_haskell/c... ([deleted] = Chris Doner)
Try map reverse ["abc", "123"] instead, which it does know how to print.
This looks like the kind of thing I get when my C linker has horribly choked on my code, what is the benefit of displaying: M1690418375.show_M1690418375 to the user? What should I do with that piece of information?
How do I 'add an instance declaration for (GHC.Show.Show ([[a0]] -> [[a0]]))'? I'm guessing that this is basically "suggesting" I implement printing for all functions? Or just for map? I'm not sure. I'm sure I'm not doing it, and it may well not even be possible?
> let foo = map reverse
As the error message "clearly" says, the result "map reverse" is a function, which doesn't have a printed representation. You might think that all objects would at the minimum have a default printable representation as "[Object 0x011432542]" or something, but they don't. As always with haskell, the idea is to catch mistakes at compile time: in this case, mistakes where you wanted to show something meaningful to the user, but forgot to define how that kind of object should be printed.