Created
January 5, 2013 15:17
-
-
Save daenomo/4462057 to your computer and use it in GitHub Desktop.
最近見たニュースにちなんでhaskellのclassの使い方を練習してみた。まだよくわからん。
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
| data System = System deriving (Show) | |
| class SIer a where | |
| makeTokkyoSystem :: a -> Maybe System | |
| makeTokkyoSystem a = Just System | |
| data Toshiba = Toshiba Int | |
| instance SIer Toshiba where | |
| makeTokkyoSystem a = Nothing | |
| main :: IO () | |
| main = do | |
| print (makeTokkyoSystem (Toshiba 5400000000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment