[email protected]
[Top] [All Lists]

[Haskell-cafe] What's going on here?

Subject: [Haskell-cafe] What's going on here?
From: michael rice
Date: Sat, 16 Jan 2010 19:02:59 -0800 PST
I don't see anything wrong with this function, which just subtracts 1 from the first element of an Int list (if there is a first element).

Michael

My function:

dropFirst :: [Int] -> [Int]
dropFirst [] = []
dropFirst (x:xs) = (x-1) : xs

My output:

> :l dropfirst
[1 of 1] Compiling Main             ( dropfirst.hs, interpreted )
Ok, modules loaded: Main.
*Main> dropFirst [3 4 5 6]

<interactive>:1:11:
    No instance for (Num (t -> t1 -> t2 -> Int))
      arising from the literal `3' at <interactive>:1:11-17
    Possible fix:
      add an instance declaration for (Num (t -> t1 -> t2 -> Int))
    In the _expression_: 3 4 5 6
    In the first argument of `dropFirst', namely `[3 4 5 6]'
    In the _expression_: dropFirst [3 4 5 6]
*Main>


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
<Prev in Thread] Current Thread [Next in Thread>