Safe Haskell | None |
---|---|
Language | Haskell2010 |
Identity transformations between different Haskell types.
Synopsis
- class CanCastTo a b where
- castDummy :: ()
- checkedCoerce :: forall a b. (CanCastTo a b, Coercible a b) => a -> b
- type Coercible_ a b = (MichelsonCoercible a b, CanCastTo a b, CanCastTo b a)
- checkedCoerce_ :: forall a b s. Castable_ a b => (a ': s) :-> (b ': s)
- checkedCoercing_ :: forall a b s. Coercible_ a b => ((b ': s) :-> (b ': s)) -> (a ': s) :-> (a ': s)
- allowCheckedCoerceTo :: forall b a. Dict (CanCastTo a b)
- allowCheckedCoerce :: forall a b. Dict (CanCastTo a b, CanCastTo b a)
- coerceUnwrap :: forall newtyp inner s. (inner ~ Unwrapped newtyp, MichelsonCoercible newtyp (Unwrapped newtyp)) => (newtyp ': s) :-> (inner ': s)
- coerceWrap :: forall newtyp inner s. (inner ~ Unwrapped newtyp, MichelsonCoercible newtyp (Unwrapped newtyp)) => (inner ': s) :-> (newtyp ': s)
- toNamed :: Label name -> (a ': s) :-> (NamedF Identity a name ': s)
- fromNamed :: Label name -> (NamedF Identity a name ': s) :-> (a ': s)
- type MichelsonCoercible a b = ToT a ~ ToT b
- forcedCoerce :: Coercible a b => a -> b
- forcedCoerce_ :: MichelsonCoercible a b => (a & s) :-> (b & s)
- gForcedCoerce_ :: MichelsonCoercible (t a) (t b) => (t a ': s) :-> (t b ': s)
- fakeCoerce :: s1 :-> s2
- futureContract :: (Address ': s) :-> (FutureContract p ': s)
- unFutureContract :: (FutureContract p ': s) :-> (Address ': s)
- class Wrapped s where
Safe coercions
class CanCastTo a b where Source #
Explicitly allowed coercions.
Nothing
Instances
CanCastTo (a :: k) (a :: k) Source # | |
Defined in Lorentz.Coercions | |
CanCastTo a b => CanCastTo ([a] :: Type) ([b] :: Type) Source # | |
Defined in Lorentz.Coercions | |
SameUStoreTemplate template1 template2 => CanCastTo (UStore template1 :: Type) (UStore template2 :: Type) Source # | |
Defined in Lorentz.UStore.Migration.Base | |
SameEntries entries1 entries2 => CanCastTo (UParam entries1 :: Type) (UParam entries2 :: Type) Source # | |
Defined in Lorentz.UParam | |
CanCastTo (FutureContract p :: Type) Address Source # | |
Defined in Lorentz.Coercions | |
(CanCastTo a1 a2, CanCastTo b1 b2) => CanCastTo ((a1, b1) :: Type) ((a2, b2) :: Type) Source # | |
Defined in Lorentz.Coercions | |
(CanCastTo i1 i2, CanCastTo o1 o2) => CanCastTo (Lambda i1 o1 :: Type) (Lambda i2 o2 :: Type) Source # | |
Defined in Lorentz.Coercions | |
CanCastTo (Lambda (UStore ot1) (UStore nt1)) (Lambda (UStore ot2) (UStore nt2)) => CanCastTo (MigrationScript ot1 nt1 :: Type) (MigrationScript ot2 nt2 :: Type) Source # | |
Defined in Lorentz.UStore.Migration.Base |
checkedCoerce :: forall a b. (CanCastTo a b, Coercible a b) => a -> b Source #
Coercion in Haskell world which respects CanCastTo
.
type Coercible_ a b = (MichelsonCoercible a b, CanCastTo a b, CanCastTo b a) Source #
Coercions between a
to b
are permitted and safe.
checkedCoerce_ :: forall a b s. Castable_ a b => (a ': s) :-> (b ': s) Source #
Coerce between types which have an explicit permission for that in the
face of CanCastTo
constraint.
checkedCoercing_ :: forall a b s. Coercible_ a b => ((b ': s) :-> (b ': s)) -> (a ': s) :-> (a ': s) Source #
Pretends that the top item of the stack was coerced.
allowCheckedCoerceTo :: forall b a. Dict (CanCastTo a b) Source #
Locally provide given CanCastTo
instance.
allowCheckedCoerce :: forall a b. Dict (CanCastTo a b, CanCastTo b a) Source #
Locally provide bidirectional CanCastTo
instance.
coerceUnwrap :: forall newtyp inner s. (inner ~ Unwrapped newtyp, MichelsonCoercible newtyp (Unwrapped newtyp)) => (newtyp ': s) :-> (inner ': s) Source #
Specialized version of coerce_
to unwrap a haskell newtype.
coerceWrap :: forall newtyp inner s. (inner ~ Unwrapped newtyp, MichelsonCoercible newtyp (Unwrapped newtyp)) => (inner ': s) :-> (newtyp ': s) Source #
Specialized version of coerce_
to wrap into a haskell newtype.
toNamed :: Label name -> (a ': s) :-> (NamedF Identity a name ': s) Source #
Lift given value to a named value.
Unsafe coercions
type MichelsonCoercible a b = ToT a ~ ToT b Source #
Whether two types have the same Michelson representation.
forcedCoerce :: Coercible a b => a -> b Source #
Coercion for Haskell world.
We discourage using this function on Lorentz types, consider using coerce
instead.
One of the reasons forthat is that in Lorentz it's common to declare types as
newtypes consisting of existing primitives, and forcedCoerce
tends to ignore
all phantom type variables of newtypes thus violating their invariants.
forcedCoerce_ :: MichelsonCoercible a b => (a & s) :-> (b & s) Source #
Convert between values of types that have the same representation.
This function is not safe in a sense that this allows breaking invariants of
casted type (example: UStore
) or may stop compile on code changes (example:
coercion of pair to a datatype with two fields will break if new field is
added).
Still, produced Michelson code will always be valid.
Prefer using one of more specific functions from this module.
gForcedCoerce_ :: MichelsonCoercible (t a) (t b) => (t a ': s) :-> (t b ': s) Source #
fakeCoerce :: s1 :-> s2 Source #
Convert between two stacks via failing.
Coercions for some basic types
futureContract :: (Address ': s) :-> (FutureContract p ': s) Source #
Make up a FutureContract
.
unFutureContract :: (FutureContract p ': s) :-> (Address ': s) Source #
Get address referred by FutureContract
.
Re-exports
Wrapped
provides isomorphisms to wrap and unwrap newtypes or
data types with one constructor.
Nothing
_Wrapped' :: Iso' s (Unwrapped s) #
An isomorphism between s
and a
.
If your type has a Generic
instance, _Wrapped'
will default to _GWrapped'
,
and you can choose to not override it with your own definition.