Created
July 31, 2012 12:33
-
-
Save joker1007/3216725 to your computer and use it in GitHub Desktop.
This file contains 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, UndecidableInstances #-} | |
class Color a where | |
toValue :: a -> (Int, Int, Int) | |
data Red = Red deriving Show | |
data Blue = Blue deriving Show | |
instance Color Red where | |
toValue _ = (255, 0, 0) | |
instance Color Blue where | |
toValue _ = (0, 255, 0) | |
class YesNo a where | |
yesno :: a -> Bool | |
instance YesNo Char where | |
yesno _ = True | |
instance YesNo [a] where | |
yesno [] = False | |
yesno _ = True | |
instance (Integral a) => YesNo a where | |
yesno n | |
| toInteger n == 0 = False | |
| otherwise = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment