[Haskell-beginners] deducing type of multi-parameter type class
Alex
a.p.katovsky at googlemail.com
Thu Jul 15 01:59:15 EDT 2010
Hi,
I'm trying to get the following code to compile:
======= Main.hs ==========
import IO
data MyInt = MyInt Int
data MyString = MyString String deriving Show
class Show b => MyClass a b where
fn :: a -> b
instance MyClass MyInt MyString where
fn (MyInt i) = MyString (show i)
myprint :: (MyClass a b) => a -> IO ()
myprint a = putStrLn $ show (fn a)
main = myprint 3
======= Main.hs ==========
with |ghc Main.hs -XMultiParamTypeClasses|. However, the compiler cannot
deduce the type of the |b| type variable (which in this case is
|MyString|). How can I explicitly tell this information to the compiler?
Many thanks,
Alex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100715/cb046987/attachment.html
More information about the Beginners
mailing list