Skip to content

Instantly share code, notes, and snippets.

@RaitoBezarius
Created November 18, 2019 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaitoBezarius/1ea4801ed61290400efd195fa02a1754 to your computer and use it in GitHub Desktop.
Save RaitoBezarius/1ea4801ed61290400efd195fa02a1754 to your computer and use it in GitHub Desktop.
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