Skip to content

Commit

Permalink
Merge pull request #32 from fumieval/master
Browse files Browse the repository at this point in the history
Add instances for Identity and Const
  • Loading branch information
mboes committed May 13, 2018
2 parents 3284c41 + 459aea7 commit c8b1cda
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Language/Haskell/TH/Lift.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ import GHC.Exts (Char(..))
import GHC.Prim (Char#)
#endif /* !(MIN_VERSION_template_haskell(2,11,0)) */

import Control.Applicative
#if MIN_VERSION_template_haskell(2,8,0)
import Data.Char (ord)
#endif /* !(MIN_VERSION_template_haskell(2,8,0)) */
#if MIN_VERSION_base(4,8,0)
import Data.Functor.Identity
#endif
#if !(MIN_VERSION_template_haskell(2,10,0))
import Data.Ratio (Ratio)
#endif /* !(MIN_VERSION_template_haskell(2,10,0)) */
Expand Down Expand Up @@ -288,3 +292,11 @@ instance Lift () where
instance Integral a => Lift (Ratio a) where
lift x = return (LitE (RationalL (toRational x)))
#endif

#if MIN_VERSION_base(4,8,0)
instance Lift a => Lift (Identity a) where
lift = appE (conE 'Identity) . lift . runIdentity
#endif

instance Lift a => Lift (Const a b) where
lift = appE (conE 'Const) . lift . getConst

0 comments on commit c8b1cda

Please sign in to comment.