packages feed

witch-1.2.3.0 / source / library / Witch / Lift.hs

{-# LANGUAGE ExplicitForAll #-}module Witch.Lift whereimport qualified Data.Typeable as Typeableimport qualified Language.Haskell.TH.Syntax as THimport qualified Witch.TryFrom as TryFromimport qualified Witch.Utility as Utility-- | This is like 'Utility.unsafeFrom' except that it works at compile time-- rather than runtime.---- > -- Avoid this:-- > unsafeFrom @s "some literal"-- >-- > -- Prefer this:-- > $$(liftedFrom @s "some literal")liftedFrom ::  forall source target m.  ( TryFrom.TryFrom source target,    TH.Lift target,    Show source,    Typeable.Typeable source,    Typeable.Typeable target,    TH.Quote m  ) =>  source ->  TH.Code m targetliftedFrom = TH.liftTyped . Utility.unsafeFrom-- | This is like 'Utility.unsafeInto' except that it works at compile time-- rather than runtime.---- > -- Avoid this:-- > unsafeInto @t "some literal"-- >-- > -- Prefer this:-- > $$(liftedInto @t "some literal")liftedInto ::  forall target source m.  ( TryFrom.TryFrom source target,    TH.Lift target,    Show source,    Typeable.Typeable source,    Typeable.Typeable target,    TH.Quote m  ) =>  source ->  TH.Code m targetliftedInto = liftedFrom