Safe Haskell | None |
---|---|
Language | Haskell2010 |
A small singleton core module
A trimmed down core version of the singletons library made for my use case or more specifically Hreq but still general enough for similar use cases.
Motivation
The singleton library has pretty long compile times which can be hard to justify when you are using only a small portion of it. It is also not backward compatible with previous GHC releases. So if you want to support earlier GHC releases in a library that depends on singletons, you are pretty much left to the mercy of CPP hacks and careful Cabal dependency configurations.
Attribution
Some of the code in this module was directly borrowed from the Singletons library
Synopsis
- type family Sing :: k -> Type
- class SingI a where
- data SNat (n :: Nat) = KnownNat n => SNat
- data SSymbol (n :: Symbol) = KnownSymbol n => SSym
- withKnownNat :: Sing n -> (KnownNat n => r) -> r
- withKnownSymbol :: Sing n -> (KnownSymbol n => r) -> r
- data SList :: [k] -> Type where
- data STuple2 (a :: (k1, k2)) where
- data STypeRep :: Type -> Type where
Sing Type family
type family Sing :: k -> Type Source #
Instances
type Sing Source # | |
Defined in Data.Singletons | |
type Sing Source # | |
Defined in Data.Singletons | |
type Sing Source # | |
Defined in Data.Singletons | |
type Sing Source # | |
Defined in Data.Singletons | |
type Sing Source # | |
Defined in Hreq.Core.API.Request | |
type Sing Source # | |
Defined in Hreq.Core.API.Response | |
type Sing Source # | |
Defined in Hreq.Core.API.Internal | |
type Sing Source # | |
Defined in Data.Singletons |
Instances
Type-lits
withKnownNat :: Sing n -> (KnownNat n => r) -> r Source #
Given a singleton for Nat
, call something requiring a
KnownNat
instance.
withKnownSymbol :: Sing n -> (KnownSymbol n => r) -> r Source #
Given a singleton for Symbol
, call something requiring
a KnownSymbol
instance.