Bounded型クラス
上限と下限を持つ
e.g. Int(固定調整数)
code:hs
class Bounded a where
minBound, maxBound :: a
例
code:hs
instance Bounded Bool where
minBound = False
maxBound = True
code:hs
data Bearing = North | East | South | West deriving (Bounded)
以下と同じ
code:hs
data Bearing = North | East | South | West
instance Bounded Bearing where
minBound = North
maxBound = West
最初に宣言したNorthが上限になり、最後のWestが下限になる
ほんま?