module Lorentz.Wrappable
( Unwrappable (..)
, Wrappable
) where
import Data.Fixed (Fixed(..))
import GHC.Generics
import GHC.TypeLits
import Morley.Michelson.Typed (ToT)
import Morley.Util.Named
class ToT s ~ ToT (Unwrappabled s) => Unwrappable (s :: Type) where
type Unwrappabled s :: Type
type Unwrappabled s = GUnwrappabled s (Rep s)
class Unwrappable s => Wrappable (s :: Type)
type family GUnwrappabled (orig :: Type) (rep :: Type -> Type) :: Type where
GUnwrappabled _ (D1 ('MetaData _ _ _ 'True) (C1 _ (S1 _ (Rec0 a)))) = a
GUnwrappabled orig _ =
TypeError ('Text "Type " ':<>: 'ShowType orig ':<>: 'Text " is not a newtype")
instance Unwrappable (NamedF Identity a name) where
type Unwrappabled (NamedF Identity a name) = a
instance Wrappable (NamedF Identity a name)
instance Unwrappable (NamedF Maybe a name) where
type Unwrappabled (NamedF Maybe a name) = Maybe a
instance Wrappable (NamedF Maybe a name)
instance Unwrappable (Fixed a) where
type Unwrappabled (Fixed a) = Integer