Skip to content

Instantly share code, notes, and snippets.

@daenomo
Created January 5, 2013 15:17
Show Gist options
  • Select an option

  • Save daenomo/4462057 to your computer and use it in GitHub Desktop.

Select an option

Save daenomo/4462057 to your computer and use it in GitHub Desktop.
最近見たニュースにちなんでhaskellのclassの使い方を練習してみた。まだよくわからん。
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