Beta Reduction, undefined vs Type Classes
Jared Warren
warren at cs.queensu.ca
Sun Nov 9 15:44:25 EST 2003
Consider:
> class Thing t where
> thing :: t
>
> instance Thing Int where
> thing = 0
>
> instance Thing Char where
> thing = 'a'
Can someone please explain why
> fst (1,thing)
...gets an 'ambiguous type variable' error, but
> fst (1,undefined)
...doesn't? And is there anything I can change to make the former work
as well? Even modifying fst doesn't work:
> fst' :: Thing b => (a,b) -> a
> fst' (~a,~b) = a
--
~ Jared Warren <warren at cs.queensu.ca>
Computing Science, Queen's University
More information about the Haskell-Cafe
mailing list