compdata 0.6.1 → 0.6.1.1
raw patch · 3 files changed
+43/−11 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Comp.Desugar: instance [overlap ok] (Desugar f g0, Desugar g0 g0) => Desugar (f :+: g0) g0
+ Data.Comp.Automata: instance Functor Sig
+ Data.Comp.Desugar: instance [overlap ok] (Desugar f h, Desugar g h) => Desugar (f :+: g) h
Files
- compdata.cabal +2/−8
- src/Data/Comp/Automata.hs +35/−1
- src/Data/Comp/Desugar.hs +6/−2
compdata.cabal view
@@ -1,5 +1,5 @@ Name: compdata-Version: 0.6.1+Version: 0.6.1.1 Synopsis: Compositional Data Types Description: @@ -152,11 +152,6 @@ examples/Examples/MultiParam/Lambda.hs examples/Examples/MultiParam/FOL.hs -flag benchmark- description: Build benchmark executable.- default: False-- library Exposed-Modules: Data.Comp, Data.Comp.Annotation,@@ -283,8 +278,6 @@ Build-Depends: base == 4.*, template-haskell, containers, mtl, QuickCheck >= 2, derive, deepseq, th-expand-syns, transformers hs-source-dirs: src ghc-options: -W- if flag(benchmark)- buildable: False Test-Suite test@@ -301,6 +294,7 @@ -- Disable short-cut fusion rules in order to compare optimised and unoptimised code. cpp-options: -DNO_RULES Build-Depends: base == 4.*, template-haskell, containers, mtl, QuickCheck >= 2, derive, deepseq, criterion, random, uniplate, th-expand-syns, transformers+ source-repository head type: hg
src/Data/Comp/Automata.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Rank2Types, FlexibleContexts, ImplicitParams, GADTs, TypeOperators #-}+{-# LANGUAGE Rank2Types, FlexibleContexts, ImplicitParams, GADTs, TypeOperators, DeriveFunctor #-} -------------------------------------------------------------------------------- -- |@@ -275,6 +275,40 @@ -- to an extended state space. type DUpState f p q = forall a . (?below :: a -> p, ?above :: p, q :< p) => f a -> q+++-- type QHom f q g = forall a . (?below :: a -> q, ?above :: q) => f a -> Context g a++homToState :: Functor g => QHom f p g -> DUpState f (Term g, p) (Term g)+homToState hom = appCxt . fmap below . hom'+ where hom' = explicit hom (snd ?above) (snd . ?below)++-- runQHom :: (Traversable f, Functor g) =>+-- DUpState f (u,d) u -> DDownState f (u,d) d -> +-- QHom f (u,d) g ->+-- d -> Term f -> (u, Term g)+-- runDState :: DUpState f (u, d) u -> DDownState f (u, d) d -> d -> Term f -> uSource++data Sig a+ = X+ | Const Integer+ | Add a a+ deriving Functor++isConst :: UpState Sig (Maybe Integer)+isConst (Const a) = Just a+isConst (Add (Just a) (Just b)) = Just (a + b)+isConst _ = Nothing++trans :: QHom Sig (Maybe Integer) Sig+trans a | Just c <- above = simpCxt $ Const c+ | otherwise = simpCxt a++runIt :: Term Sig -> Term Sig+runIt = runUpHom isConst trans+++ -- | This combinator turns an arbitrary DUTA into a GDUTA.
src/Data/Comp/Desugar.hs view
@@ -16,7 +16,7 @@ module Data.Comp.Desugar where import Data.Comp-import Data.Comp.Derive+import Data.Comp.Ops -- |The desugaring term homomorphism. class (Functor f, Functor g) => Desugar f g where@@ -25,7 +25,11 @@ desugHom' :: Alg f (Context g a) desugHom' x = appCxt (desugHom x) -$(derive [liftSum] [''Desugar])++instance (Desugar f h, Desugar g h) => Desugar (f :+: g) h where+ desugHom (Inl x) = desugHom x+ desugHom (Inr x) = desugHom x+ -- |Desugar a term. desugar :: Desugar f g => Term f -> Term g