Haskell Newbie: No Instance for Show in Map Function

In GHCI, I type the following:

map (+1) [1..10]

which returns [2,3,4,5,6,7,8,9,10,11]

So far so good.

Now I type:

min (map (+1) [1..10])

and I get the following error message:

No instance for (Show ([b0] -> [b0]))
  arising from a use of `print'
Possible fix: add an instance declaration for (Show ([b0] -> [b0]))
In a stmt of an interactive GHCi command: print it

This is very strange for me. Why does Haskell think I'm trying to print any arguments and how to fix it?

+5
source share
1 answer

The problem is that it mintakes two arguments (and returns a minimum of two), but you specified only one; you want a minimumversion that works in lists.

, - , GHCi , , min , . 1 GHCi , , Show, - , .

1 Haskell , , ; , , , Integer -> Integer -> Integer, Integer -> (Integer -> Integer) - , Integer , , Integer. , , !

+12

All Articles