Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
- module UpperLowerBounded where
- class LowerBounded a where
- lowerBound :: a
- class UpperBounded a where
- upperBound :: a
- instance {-# INCOHERENT #-} Bounded a => LowerBounded a where
- lowerBound = minBound
- instance Bounded a => UpperBounded a where
- upperBound = maxBound
- instance {-# INCOHERENT #-} (LowerBounded a, UpperBounded a) => Bounded a where
- minBound = lowerBound
- maxBound = upperBound
- data Foo = A | B deriving (Show)
- data Bar = C | D | E deriving (Show)
- instance Bounded Foo where
- minBound = A
- maxBound = B
- instance LowerBounded Bar where
- lowerBound = C
- instance UpperBounded Bar where
- upperBound = E
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement