3 ms·
I'm not sure what you expected. It's just saying it doesn't know how to print a function that takes as input a list of lists of type a0 and returns a list of li
by ent 14y ago
I'm not sure what you expected. It's just saying it doesn't know how to print a function that takes as input a list of lists of type a0 and returns a list of lists of type a0.
Try map reverse ["abc", "123"] instead, which it does know how to print.
- CJefferson 14y agoI don't know what I expected. I don't know Haskell. I am vaguely familiar with other functional languages and thought I would explore. However, this system (or Haskell) are not super-friendly to exploring currying it seems.
- jerf 14y agoAs other people are asking, though, what did you expect? Serious question. What you got was perhaps phrased in terms you're not used to, but there's not much else you could have gotten.
- CJefferson 14y agoI understand curried functions are a very common thing to build in functional languages. So some nicely 'pretty printed' version would be nice. Or at least the least some kind of "can't print a function" in a nice way. 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?
- nandemo 14y agoI hear you. When I started learning Haskell I was also somewhat frustrated by some error messages. But it's far from an insurmountable problem, if you're really interested in learning the language. My suggestion is, (i) use ghc and ghci. TryHaskell isn't actively mantained AFAIK. (ii) if you find a cryptic error message, first google it and learn the immediate fix, without trying to understand all the details. Of course, eventually you'll have to learn the details, but there's no reason it should be a blocking issue in the beginning. In any case this is my short-ish, inaccurate version of "the details": 1. In the interpreter, there's an implicit "print foo" when you type "foo". 2. "print foo" expects a foo of any type t as long as t is an instance of the typeclass Show, meaning there must be a show function associated with t that turns t's into Strings. Roughly, that would be as if we had a Java where the method toString (=show) is not part of Object, but rather of an interface Showable, which not all classes have to implement. 3. In Haskell, it was decided that function types shouldn't be instances of Show because they don't have a sensible show implementation. In theory you can have a show implementation that prints "this is function" for all functions, but that's of limited usefulness. 4. The compiler's error message is just an instance of a more general message: a value foo is used in a place that expects a type that's an instance of SomeTypeClass, but foo turns out to be of a type T that isn't. For instance, if you try this on ghci: > 'a' + 'b' you'll get a similar error message, because '+' expects 2 arguments of a type that's an instance of typeclass Num, but 'a' and 'b' are of type Char which is not a Num in Haskell. In theory, the compiler could be "hardcoded" to print a special error message when SomeTypeClass happens to be Show, such as "can't print that type". That would be easier for beginners, but would add some complexity to the compiler. 5. The "M1690418375.show_M1690418375" thing is probably an artifact of the way TryHaskell was implemented. In ghci, you simply get this instead: arising from a use of `print' I hope this helps.