Created
November 18, 2019 22:28
-
-
Save RaitoBezarius/1ea4801ed61290400efd195fa02a1754 to your computer and use it in GitHub Desktop.
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 PosInf a = Infinity | Num a deriving (Show, Read, Eq) | |
instance Ord a => Ord (PosInf a) where | |
compare Infinity Infinity = EQ | |
compare Infinity Num{} = GT | |
compare Num{} Infinity = LT | |
compare (Num a) (Num b) = compare a b | |
pInfty :: PosInf a | |
pInfty = Infinity | |
give_it_a_try :: PosInf a => a -> a | |
give_it_a_try a b | |
| a == Infinity || b == Infinity -> Infinity | |
| otherwise = a + b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment