Last active
December 20, 2015 20:49
-
-
Save klapaucius/6193028 to your computer and use it in GitHub Desktop.
Fixed+TypeNats
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
Prelude> :set -XDataKinds | |
Prelude> :set -XKindSignatures | |
Prelude> :set -XScopedTypeVariables | |
Prelude> import Data.Fixed | |
Prelude Data.Fixed> import GHC.TypeLits | |
Prelude Data.Fixed GHC.TypeLits> | |
data E (a :: Nat) | |
Prelude Data.Fixed GHC.TypeLits> | |
instance SingI a => HasResolution (E a) where resolution _ = 10 ^ fromSing (sing :: Sing a) | |
Prelude Data.Fixed GHC.TypeLits> fromInteger 10 :: Fixed (E 2) | |
10.00 | |
Prelude Data.Fixed GHC.TypeLits> fromInteger 10 :: Fixed (E 5) | |
10.00000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment