Why is that?
I had thought that the ambiguity was referring to the type of [] in the print statement, i.e., that GHC can't figure out the type of []. If I modify the print statement to be print ( null' ([] :: [Int]) ) everything is ok.
But if that's the case, why is this not a problem at the interactive level?
Here is a related question. In the following what does it mean to say that x is of type [a] where "a" is a type variable?
Prelude> let x = []
x :: [a]
For example,
Prelude> x == (tail [1 :: Int])
True
it :: Bool
Prelude> x == (tail [1 :: Float])
True
it :: Bool
Prelude> (tail [1 :: Int]) == (tail [1 :: Float])
<interactive>:1:28:
Couldn't match expected type `Int' against inferred type `Float'
In the expression: 1 :: Float
In the first argument of `tail', namely `[1 :: Float]'
In the second argument of `(==)', namely `(tail [1 :: Float])'
Can a value like the value of x really be of an incompletely specified type?
I couldn't do that in the file.
When I tried the following in the file,
print (null' ([] :: (Eq a) => a))
I got this error message on loading the file.
Null.hs:3:24:
Couldn't match expected type `a1' against inferred type `[a]'
`a1' is a rigid type variable bound by
an expression type signature at Null.hs:3:34
In the first argument of `null'', namely `([] :: (Eq a) => a)'
In the first argument of `print', namely
`(null' ([] :: (Eq a) => a))'
In the expression: print (null' ([] :: (Eq a) => a))
Thanks.
-- Russ