Last active
October 17, 2016 09:00
-
-
Save esoeylemez/010011b6b78dc1b9d7dcdec9d4249212 to your computer and use it in GitHub Desktop.
This file contains 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
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE RankNTypes #-} | |
data Number | |
= DoubleNum !Double | |
| IntegerNum !Integer | |
| IntNum !Int | |
| RationalNum !Rational | |
withNumber :: (c Double, c Int, c Integer, c Rational) => (forall a. (c a) => a -> r) -> Number -> r | |
withNumber f (DoubleNum x) = f x | |
withNumber f (IntegerNum x) = f x | |
withNumber f (IntNum x) = f x | |
withNumber f (RationalNum x) = f x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment