module Lorentz.Coercions
( Coercible_
, coerce_
, gcoerce_
, fakeCoerce
, coerceUnwrap
, coerceWrap
, toNamed
, fromNamed
, futureContract
, unFutureContract
, Wrapped (..)
) where
import Control.Lens (Wrapped(..))
import Data.Vinyl.Derived (Label)
import Named (NamedF)
import Lorentz.Base
import Lorentz.Instr
import Lorentz.Value
import Michelson.Typed
type Coercible_ a b = ToT a ~ ToT b
coerce_ :: Coercible_ a b => a & s :-> b & s
coerce_ = I Nop
gcoerce_ :: Coercible_ (t a) (t b) => t a : s :-> t b : s
gcoerce_ = coerce_
fakeCoerce :: s1 :-> s2
fakeCoerce = unit # I FAILWITH
coerceWrap
:: Coercible_ newtyp (Unwrapped newtyp)
=> Unwrapped newtyp : s :-> newtyp : s
coerceWrap = coerce_
coerceUnwrap
:: Coercible_ newtyp (Unwrapped newtyp)
=> newtyp : s :-> Unwrapped newtyp : s
coerceUnwrap = coerce_
toNamed :: Label name -> a : s :-> NamedF Identity a name : s
toNamed _ = coerceWrap
fromNamed :: Label name -> NamedF Identity a name : s :-> a : s
fromNamed _ = coerceUnwrap
futureContract :: Address : s :-> FutureContract p : s
futureContract = coerce_
unFutureContract :: FutureContract p : s :-> Address : s
unFutureContract = coerce_