Created
January 18, 2012 12:17
-
-
Save kavu/1632741 to your computer and use it in GitHub Desktop.
Haskell class experiments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances, IncoherentInstances #-} | |
class (MyClass t) where | |
doShow :: (Show t) => t -> String | |
instance (MyClass String) where | |
doShow x = "Your string is " ++ x | |
instance (MyClass t) where | |
doShow x = "Your parameter is " ++ show x | |
instance (MyClass [t]) where | |
doShow x = do | |
let list = show $ x ++ reverse x | |
"Your new List is " ++ list | |
some :: (MyClass t, Show t) => t -> String | |
some = doShow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment