[Haskell-cafe] Typeclasses and implicit parameters
ajb at spamcop.net
ajb at spamcop.net
Fri Aug 10 01:45:06 EDT 2007
{-# OPTIONS -fglasgow-exts #-}
-- G'day everyone.
-- This is okay.
f1 :: (?foo :: String) => String
f1 = ?foo
-- So is this.
f2 :: (Show a, ?foo :: a) => a -> String
f2 _ = show ?foo
-- Hugs allows this. GHC rejects it on the grounds that "a" is unused
-- on the right-hand side of the (=>). I think this is arguably a bug
-- in GHC.
f3 :: (Show a, ?foo :: a) => String
f3 = show ?foo
-- GHC rejects this. Hugs compiles it, but I can't call it as
-- let ?foo = "Hello" in show Foo
--
-- Is there a good reason to disallow this?
data Foo = Foo
instance (?foo :: String) => Show Foo where
showsPrec _ Foo = showString ?foo . showString "Foo"
-- Cheers,
-- Andrew Bromage
More information about the Haskell-Cafe
mailing list