2021-04-10 20:56:15 +03:00
|
|
|
{-# LANGUAGE AllowAmbiguousTypes #-}
|
|
|
|
{-# LANGUAGE ExplicitForAll #-}
|
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
|
|
|
|
|
|
module Witch.Lift where
|
|
|
|
|
|
|
|
import qualified Data.Typeable as Typeable
|
|
|
|
import qualified Language.Haskell.TH.Syntax as TH
|
|
|
|
import qualified Witch.Identity as Identity
|
|
|
|
import qualified Witch.TryCast as TryCast
|
2021-04-11 18:11:58 +03:00
|
|
|
import qualified Witch.Utility as Utility
|
2021-04-10 20:56:15 +03:00
|
|
|
|
|
|
|
liftedCast
|
2021-04-11 17:16:45 +03:00
|
|
|
:: forall source target m
|
2021-04-17 16:48:16 +03:00
|
|
|
. ( TryCast.TryCast source target
|
|
|
|
, TH.Lift target
|
|
|
|
, Show source
|
|
|
|
, Typeable.Typeable source
|
|
|
|
, Typeable.Typeable target
|
|
|
|
, TH.Quote m
|
|
|
|
)
|
|
|
|
=> source
|
2021-04-10 20:56:15 +03:00
|
|
|
-> TH.Code m target
|
2021-04-11 18:11:58 +03:00
|
|
|
liftedCast = TH.liftTyped . Utility.unsafeCast
|
2021-04-10 20:56:15 +03:00
|
|
|
|
|
|
|
liftedFrom
|
2021-04-11 17:16:45 +03:00
|
|
|
:: forall s target m source
|
2021-04-17 16:48:16 +03:00
|
|
|
. ( Identity.Identity s ~ source
|
|
|
|
, TryCast.TryCast source target
|
|
|
|
, TH.Lift target
|
|
|
|
, Show source
|
|
|
|
, Typeable.Typeable source
|
|
|
|
, Typeable.Typeable target
|
|
|
|
, TH.Quote m
|
|
|
|
)
|
|
|
|
=> source
|
2021-04-10 20:56:15 +03:00
|
|
|
-> TH.Code m target
|
|
|
|
liftedFrom = liftedCast
|
|
|
|
|
|
|
|
liftedInto
|
2021-04-11 17:16:45 +03:00
|
|
|
:: forall t source m target
|
2021-04-17 16:48:16 +03:00
|
|
|
. ( Identity.Identity t ~ target
|
|
|
|
, TryCast.TryCast source target
|
|
|
|
, TH.Lift target
|
|
|
|
, Show source
|
|
|
|
, Typeable.Typeable source
|
|
|
|
, Typeable.Typeable target
|
|
|
|
, TH.Quote m
|
|
|
|
)
|
|
|
|
=> source
|
2021-04-10 20:56:15 +03:00
|
|
|
-> TH.Code m target
|
|
|
|
liftedInto = liftedCast
|