[Haskell-cafe] unification would give infinite type
Emil Axelsson
emax at cs.chalmers.se
Tue Dec 4 09:00:29 EST 2007
Hi,
Depending on what you want, you should either remove 'return' or change to
'foldM' (from Control.Monad). If you choose the latter, you also need to add a
type signature to f (because of the monomorphism restriction).
/ Emil
On 2007-12-04 14:43, Rafael wrote:
> Hi... I give this error using hugs for the code:
>
> ---------------------------------------------------
> f = foldl (\x y -> add x y) 0 [1,2,3]
> add x y = return (x + y)
> ---------------------------------------------------
> I try:
>
> f = foldl (\x y -> counter x y) (return 0) [1,2,3]
>
> but it dont solve, and with ghci:
>
> "
> Occurs check: cannot construct the infinite type: b = m b
> Expected type: b
> Inferred type: m b
> In the expression: add x y
> In a lambda abstraction: \ x y -> add x y
> "
>
> thnks.
>
> att
> Rafael
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list