Created
March 4, 2015 00:05
-
-
Save xenophobia/69d295b0987c906fcd37 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
data T a = T {element :: a, element2 :: a, element3 :: String} deriving (Show) | |
class F a where | |
mes :: a -> String | |
instance F Int where mes _ = "Int" | |
instance F Double where mes _ = "Double" | |
mkDefaultT :: (F a, Num a) => a -> T a | |
mkDefaultT x = T x x (mes x) | |
defaultT :: (F a, Num a) => T a | |
defaultT = mkDefaultT 0 | |
-- error! | |
modifiedT :: T Double | |
modifiedT = defaultT { | |
element = 1.0 :: Double | |
, element2 = 0.0 :: Double | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment