[Haskell-cafe] Ambiguous type variable

Jacek Generowicz jacek.generowicz at cern.ch
Fri Oct 15 18:47:06 EDT 2010


-- Given a definition of view which is essentially a synonym for show:

class View a where
     view :: a -> String

instance View Int where
     view = show

-- why does "show 2" compile, while "view 2" gives an
-- 'Ambiguous type variable' error

fine                  = view (2::Int)
noProblem             = show 2
ambiguousTypeVariable = view 2



More information about the Haskell-Cafe mailing list