haskell-src-meta 0.8.4 → 0.8.5
raw patch · 7 files changed
+48/−10 lines, 7 filesdep ~haskell-src-extsdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: haskell-src-exts, template-haskell
API changes (from Hackage documentation)
+ Language.Haskell.Meta.Syntax.Translate: toTupEl :: ToExp a => a -> Exp
Files
- ChangeLog +3/−0
- examples/BF.hs +14/−0
- examples/HsHere.hs +6/−2
- examples/SKI.hs +4/−0
- haskell-src-meta.cabal +2/−2
- src/Language/Haskell/Meta/Syntax/Translate.hs +13/−5
- src/Language/Haskell/Meta/Utils.hs +6/−1
ChangeLog view
@@ -1,3 +1,6 @@+0.8.5:+- Compatibility with template-haskell shipped with GHC 8.10+ 0.8.4: - Bump base and template-haskell library to versions shipped with GHC 7.10 - Compatibility with haskell-src-exts 1.22
examples/BF.hs view
@@ -2,6 +2,7 @@ {-# OPTIONS_GHC -fno-warn-name-shadowing #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} module BF (@@ -65,6 +66,19 @@ lift MovL = [|MovL|] lift MovR = [|MovR|] lift (While xs) = [|While $(lift xs)|]++#if MIN_VERSION_template_haskell(2,16,0)+ liftTyped = unsafeTExpCoerce . lift+ -- TODO: get stylish haskell to be happy w/ the below+ -- liftTyped Inp = [||Inp||]+ -- liftTyped Out = [||Out||]+ -- liftTyped Inc = [||Inc||]+ -- liftTyped Dec = [||Dec||]+ -- liftTyped MovL = [||MovL||]+ -- liftTyped MovR = [||MovR||]+ -- liftTyped (While xs) = [||While $$(liftTyped xs)||]+#endif+ type Ptr = Int newtype Mem = Mem (IntMap Int) deriving (Show)
examples/HsHere.hs view
@@ -2,6 +2,7 @@ {-# OPTIONS_GHC -fno-warn-name-shadowing #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE TemplateHaskell #-}@@ -58,8 +59,11 @@ ,quoteExp = hereExpQ ,quotePat = herePatQ} -instance Lift Here- where lift = liftHere+instance Lift Here where+ lift = liftHere+#if MIN_VERSION_template_haskell(2,16,0)+ liftTyped = unsafeTExpCoerce . lift -- TODO: the right way?+#endif liftHere :: Here -> ExpQ liftHere (TextH s) = (litE . stringL) s
examples/SKI.hs view
@@ -4,6 +4,7 @@ {-# OPTIONS_GHC -fno-warn-type-defaults #-} {-# OPTIONS_GHC -fno-warn-missing-signatures #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE TemplateHaskell #-}@@ -70,6 +71,9 @@ instance Lift SKI where lift = liftSKI+#if MIN_VERSION_template_haskell(2,16,0)+ liftTyped = unsafeTExpCoerce . lift -- TODO: the right way?+#endif liftSKI (E e) = return e liftSKI a = go a
haskell-src-meta.cabal view
@@ -1,5 +1,5 @@ name: haskell-src-meta-version: 0.8.4+version: 0.8.5 cabal-version: >= 1.8 build-type: Simple license: BSD3@@ -21,7 +21,7 @@ haskell-src-exts >= 1.18 && < 1.23, pretty >= 1.0 && < 1.2, syb >= 0.1 && < 0.8,- template-haskell >= 2.10 && < 2.16,+ template-haskell >= 2.10 && < 2.17, th-orphans >= 0.12 && < 0.14 if impl(ghc < 7.8)
src/Language/Haskell/Meta/Syntax/Translate.hs view
@@ -75,6 +75,14 @@ nonsense fun inparticular thing = error . concat $ [moduleName, ".", fun, ": nonsensical: ", inparticular, ": ", show (fmap (const ()) thing)] +#if MIN_VERSION_template_haskell(2,16,0)+toTupEl :: ToExp a => a -> Maybe TH.Exp+toTupEl = Just . toExp+#else+toTupEl :: ToExp a => a -> TH.Exp+toTupEl = toExp+#endif+ ----------------------------------------------------------------------------- @@ -83,11 +91,11 @@ instance (ToExp a) => ToExp [a] where toExp = TH.ListE . fmap toExp instance (ToExp a, ToExp b) => ToExp (a,b) where- toExp (a,b) = TH.TupE [toExp a, toExp b]+ toExp (a,b) = TH.TupE [toTupEl a, toTupEl b] instance (ToExp a, ToExp b, ToExp c) => ToExp (a,b,c) where- toExp (a,b,c) = TH.TupE [toExp a, toExp b, toExp c]+ toExp (a,b,c) = TH.TupE [toTupEl a, toTupEl b, toTupEl c] instance (ToExp a, ToExp b, ToExp c, ToExp d) => ToExp (a,b,c,d) where- toExp (a,b,c,d) = TH.TupE [toExp a, toExp b, toExp c, toExp d]+ toExp (a,b,c,d) = TH.TupE [toTupEl a, toTupEl b, toTupEl c, toTupEl d] instance ToPat TH.Lit where@@ -273,8 +281,8 @@ toExp (Exts.Case _ e alts) = TH.CaseE (toExp e) (map toMatch alts) toExp (Exts.Do _ ss) = TH.DoE (map toStmt ss) toExp e@Exts.MDo{} = noTH "toExp" e- toExp (Exts.Tuple _ Exts.Boxed xs) = TH.TupE (fmap toExp xs)- toExp (Exts.Tuple _ Exts.Unboxed xs) = TH.UnboxedTupE (fmap toExp xs)+ toExp (Exts.Tuple _ Exts.Boxed xs) = TH.TupE (fmap toTupEl xs)+ toExp (Exts.Tuple _ Exts.Unboxed xs) = TH.UnboxedTupE (fmap toTupEl xs) toExp e@Exts.TupleSection{} = noTH "toExp" e toExp (Exts.List _ xs) = TH.ListE (fmap toExp xs) toExp (Exts.Paren _ e) = TH.ParensE (toExp e)
src/Language/Haskell/Meta/Utils.hs view
@@ -330,7 +330,12 @@ in replicateM n (newName "a") >>= \ns -> return (Just (LamE [ConP dConN (fmap VarP ns)]- (TupE $ fmap VarE ns)))+#if MIN_VERSION_template_haskell(2,16,0)+ (TupE $ fmap (Just . VarE) ns)+#else+ (TupE $ fmap VarE ns)+#endif+ )) #else fromDataConI (DataConI dConN ty _tyConN _fxty) = let n = arityT ty