syntactic 3.6 → 3.6.1
raw patch · 5 files changed
+43/−6 lines, 5 files
Files
- src/Data/NestTuple/TH.hs +1/−1
- src/Language/Syntactic/Functional/Sharing.hs +6/−0
- src/Language/Syntactic/Functional/Tuple/TH.hs +1/−1
- src/Language/Syntactic/TH.hs +34/−3
- syntactic.cabal +1/−1
src/Data/NestTuple/TH.hs view
@@ -51,7 +51,7 @@ -> DecsQ mkNestableInstances n = return $ map nestableInstance [2..n] where- nestableInstance w = InstanceD+ nestableInstance w = instD [] (AppT (ConT (mkName "Nestable")) tupT) [ tySynInst (mkName "Nested") [tupT] (foldNest VarT mkPairT $ toNest vars)
src/Language/Syntactic/Functional/Sharing.hs view
@@ -273,6 +273,12 @@ chooseEnvSub env (s :$ b) = chooseEnvSub env s `mplus` chooseEnv env b chooseEnvSub _ _ = Nothing +-- If `codeMotionM` loops forever, the reason may be that `castExprCM` is+-- broken. If `castExprCM` fails to cast even when it should, it means that+-- we can get into situations where `substitute` returns the same expression+-- unchanged. This in turn means that `codeMotionM` will loop, since it calls+-- itself with `codeMotionM iface $ substitute iface b x a`.+ codeMotionM :: forall sym m a . ( Equality sym , BindingDomain sym
src/Language/Syntactic/Functional/Tuple/TH.hs view
@@ -55,7 +55,7 @@ deriveSyntacticForTuples internalPred mkDomain extraConstraint n = return $ map deriveSyntacticForTuple [3..n] where- deriveSyntacticForTuple w = InstanceD+ deriveSyntacticForTuple w = instD ( concat [ map (classPred ''Syntactic ConT . return) varsT , concatMap internalPred $ map (AppT (ConT ''Internal)) varsT
src/Language/Syntactic/TH.hs view
@@ -5,6 +5,10 @@ +#if __GLASGOW_HASKELL__ < 710+import Control.Applicative+#endif+ import Language.Haskell.TH import Data.Hash (hashInt, combine)@@ -20,6 +24,12 @@ conName (RecC name args) = (name, length args) conName (InfixC _ name _) = (name, 2) conName (ForallC _ _ c) = conName c+#if __GLASGOW_HASKELL__ >= 800+conName (GadtC [n] as _) = (n, length as)+conName (RecGadtC [n] as _) = (n, length as)+ -- I don't know what it means when a `GadtC` and `RecGadtC` don't have+ -- singleton lists of names+#endif -- | Description of class methods data Method@@ -40,9 +50,9 @@ -> [Method] -- ^ Methods -> DecsQ deriveClass cxt ty clHead methods = do- t@(TyConI (DataD _ _ _ cs _)) <- reify ty+ Just cs <- viewDataDef <$> reify ty return- [ InstanceD cxt clHead $+ [ instD cxt clHead $ [ FunD method (clauses ++ extra) | MatchingMethod method mkClause extra <- methods , let clauses = [ mkClause c i nm ar | (i,c) <- zip [0..] cs@@ -90,7 +100,7 @@ :: Name -- ^ Type name -> DecsQ deriveEquality ty = do- TyConI (DataD _ _ _ cs _) <- reify ty+ Just cs <- viewDataDef <$> reify ty let equalFallThrough = if length cs > 1 then [Clause [WildP, WildP] (NormalB $ ConE 'False) []] else []@@ -180,6 +190,27 @@ -- Using `__GLASGOW_HASKELL__` instead of `MIN_VERSION_template_haskell`, -- because the latter doesn't work when the package is compiled with `-f-th`.++-- | Construct an instance declaration+instD+ :: Cxt -- ^ Context+ -> Type -- ^ Instance+ -> [Dec] -- ^ Methods, etc.+ -> Dec+#if __GLASGOW_HASKELL__ >= 800+instD = InstanceD Nothing+#else+instD = InstanceD+#endif++-- | Get the constructors of a data type definition+viewDataDef :: Info -> Maybe [Con]+#if __GLASGOW_HASKELL__ >= 800+viewDataDef (TyConI (DataD _ _ _ _ cs _)) = Just cs+#else+viewDataDef (TyConI (DataD _ _ _ cs _)) = Just cs+#endif+viewDataDef _ = Nothing -- | Portable method for constructing a 'Pred' of the form @(t1 ~ t2)@ eqPred :: Type -> Type -> Pred
syntactic.cabal view
@@ -1,5 +1,5 @@ Name: syntactic-Version: 3.6+Version: 3.6.1 Synopsis: Generic representation and manipulation of abstract syntax Description: The library provides a generic representation of type-indexed abstract syntax trees (or indexed data types in general). It also permits the definition of open syntax