4 ms·
This tells you that "map reverse" returned a function that takes a list and returns a list. This function does not have a "Show" instance (analogous to someone
by pilgrim689 14y ago
This tells you that "map reverse" returned a function that takes a list and returns a list. This function does not have a "Show" instance (analogous to someone failing to implement the "toString()" method for that type), so an error is thrown at you since it cannot possibly output something that doesn't know how to be output. Try just storing it in a variable instead.
> 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!
- nandemo 14y agoThat works on ghci but, unfortunately, Try Haskell doesn't seem to support let.
- jonke 14y agoTryHaskell uses http://hackage.haskell.org/package/mueval http://hackage.haskell.org/package/mueval and not ghci You can eval expression so following works let t ="foo" in t
- nandemo 14y agoYeah, I saw that it uses mueval, but it's still conceivable that TryHaskell itself could hack support for let on top of it. Apparently Chris planned to do it [1]. 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/c0l0xdc http://www.reddit.com/r/haskell/comments/b58rk/try_haskell/c... ([deleted] = Chris Doner)
- jonke 14y agoFair enough but you could do let f = map reverse in f ["ab", "cd"] IMHO the tryhaskell expose more or less only simple pure functions and I doubt that anyone with a real interest in haskell will get any substantial out of it. However if one is completely new to programming maybe TryHaskell and these 6 short lessons have a value.
- nandemo 14y agoAgreed. Incidentally, Chris Doner has been producing far more exciting things like Fay, so I'm not gonna complain about TryHaskell.