Skip to content

Instantly share code, notes, and snippets.

@klapaucius
Last active December 20, 2015 20:49
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 klapaucius/6193028 to your computer and use it in GitHub Desktop.
Save klapaucius/6193028 to your computer and use it in GitHub Desktop.
Fixed+TypeNats
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