I'm admittedly new to Haskell. To explore laziness, I created a function in ghci that returns its second argument:
Prelude> let latter xy = y latter :: t -> t1 -> t1
I can call it with arguments of types Char , [Char] , Num , Floating and Fractional (expressed as decimal numbers):
Prelude> latter 'x' 'y' 'y' it :: Char Prelude> latter "foo" "bar" "bar" it :: [Char] Prelude> latter 1 2 2 it :: Num t1 => t1 Prelude> latter pi pi 3.141592653589793 it :: Floating t1 => t1 Prelude> latter 0.5 0.7 0.7 it :: Fractional t1 => t1
Why am I getting a terrible error (and what does this mean) when I try to apply the latter to Fractional , expressed as a relation:
Prelude> 1/2 0.5 it :: Fractional a => a Prelude> latter 1/2 1/2 <interactive>:62:1: Could not deduce (Num (a0 -> t1 -> t1)) arising from the ambiguity check for 'it' from the context (Num (a -> t1 -> t1), Num a, Fractional (t1 -> t1)) bound by the inferred type for 'it': (Num (a -> t1 -> t1), Num a, Fractional (t1 -> t1)) => t1 -> t1 at <interactive>:62:1-14 The type variable 'a0' is ambiguous When checking that 'it' has the inferred type 'forall t1 a. (Num (a -> t1 -> t1), Num a, Fractional (t1 -> t1)) => t1 -> t1' Probable cause: the inferred type is ambiguous
source share