Safe Haskell | None |
---|---|
Language | Haskell2010 |
Type-nat utilities.
We take Peano numbers as base for operations because they make it much easer to prove things to compiler. Their performance does not seem to introduce a problem, because we use nats primarily along with stack which is a linked list with similar performance characteristics.
Many of things we introduce here are covered in type-natural
package,
but unfortunatelly it does not work with GHC 8.6 at the moment of writing
this module. We use Vinyl
as source of Peano Nat
for now.
Synopsis
- type Peano = Nat
- type family ToPeano (n :: Nat) :: Nat where ...
- type family Length l where ...
- class KnownPeano (n :: Nat) where
- peanoVal' :: forall n. KnownPeano n => Natural
- data family Sing (a :: k) :: Type
- type family At (n :: Peano) s where ...
- type family IsLongerThan (l :: [k]) (a :: Nat) :: Bool where ...
- type LongerThan l a = IsLongerThan l a ~ True
- type family RequireLongerThan (l :: [k]) (a :: Nat) :: Constraint where ...
- requiredLongerThan :: forall l a r. RequireLongerThan l a => (LongerThan l a => r) -> r
General
class KnownPeano (n :: Nat) where Source #
Instances
KnownPeano Z Source # | |
KnownPeano a => KnownPeano (S a) Source # | |
peanoVal' :: forall n. KnownPeano n => Natural Source #
data family Sing (a :: k) :: Type #
The singleton kind-indexed data family.
Instances
Eq (Sing n) Source # | |
data Sing (a :: Bool) | |
data Sing (a :: Ordering) | |
data Sing (n :: Nat) | |
data Sing (n :: Symbol) | |
Defined in Data.Singletons.TypeLits.Internal | |
data Sing (a :: ()) | |
Defined in Data.Singletons.Prelude.Instances | |
data Sing (a :: Void) | |
Defined in Data.Singletons.Prelude.Instances | |
data Sing (a :: All) | |
data Sing (a :: Any) | |
data Sing (_ :: Nat) Source # | |
data Sing (a :: CT) Source # | |
Defined in Michelson.Typed.Sing data Sing (a :: CT) where
| |
data Sing (a :: T) Source # | Instance of data family |
Defined in Michelson.Typed.Sing data Sing (a :: T) where
| |
data Sing (b :: [a]) | |
data Sing (b :: Maybe a) | |
data Sing (b :: Min a) | |
data Sing (b :: Max a) | |
data Sing (b :: First a) | |
data Sing (b :: Last a) | |
data Sing (a :: WrappedMonoid m) | |
Defined in Data.Singletons.Prelude.Semigroup.Internal data Sing (a :: WrappedMonoid m) where
| |
data Sing (b :: Option a) | |
data Sing (b :: Identity a) | |
data Sing (b :: First a) | |
data Sing (b :: Last a) | |
data Sing (b :: Dual a) | |
data Sing (b :: Sum a) | |
data Sing (b :: Product a) | |
data Sing (b :: Down a) | |
data Sing (b :: NonEmpty a) | |
data Sing (b :: Endo a) | |
data Sing (b :: MaxInternal a) | |
Defined in Data.Singletons.Prelude.Foldable data Sing (b :: MaxInternal a) where
| |
data Sing (b :: MinInternal a) | |
Defined in Data.Singletons.Prelude.Foldable data Sing (b :: MinInternal a) where
| |
data Sing (c :: Either a b) | |
data Sing (c :: (a, b)) | |
data Sing (c :: Arg a b) | |
newtype Sing (f :: k1 ~> k2) | |
data Sing (b :: StateL s a) | |
data Sing (b :: StateR s a) | |
data Sing (d :: (a, b, c)) | |
data Sing (c :: Const a b) | |
data Sing (e :: (a, b, c, d)) | |
data Sing (f :: (a, b, c, d, e)) | |
data Sing (g :: (a, b, c, d, e, f)) | |
Defined in Data.Singletons.Prelude.Instances | |
data Sing (h :: (a, b, c, d, e, f, g)) | |
Defined in Data.Singletons.Prelude.Instances |
Morley-specific utils
type family IsLongerThan (l :: [k]) (a :: Nat) :: Bool where ... Source #
Comparison of type-level naturals, as a function.
It is as lazy on the list argument as possible - there is no need to know the whole list if the natural argument is small enough. This property is important if we want to be able to extract reusable parts of code which are aware only of relevant part of stack.
IsLongerThan (_ ': _) Z = True | |
IsLongerThan (_ ': xs) (S a) = IsLongerThan xs a | |
IsLongerThan '[] _ = False |
type LongerThan l a = IsLongerThan l a ~ True Source #
Comparison of type-level naturals, as a constraint.
type family RequireLongerThan (l :: [k]) (a :: Nat) :: Constraint where ... Source #
Comparison of type-level naturals, raises human-readable compile error when does not hold.
This is for in eDSL use only, GHC cannot reason about such constraint.
requiredLongerThan :: forall l a r. RequireLongerThan l a => (LongerThan l a => r) -> r Source #
Derive LongerThan
from RequireLongerThan
.