rewriting 0.2.1 → 0.2.2
raw patch · 2 files changed
+16/−42 lines, 2 filesdep ~regular
Dependency ranges changed: regular
Files
- examples/expr/Expr.hs +7/−37
- rewriting.cabal +9/−5
examples/expr/Expr.hs view
@@ -1,4 +1,5 @@-{-# OPTIONS_GHC -fglasgow-exts #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} import Generics.Regular.Rewriting @@ -10,32 +11,17 @@ infixl 7 :**: infixl 6 :++: -data Expr = Const Int | Expr :++: Expr | Expr :**: Expr | Fun String [Expr] - deriving Show+data Expr = Const Int | Expr :++: Expr | Expr :**: Expr deriving Show -type instance PF Expr = K Int :+: I :*: I :+: I :*: I :+: K String :*: [] :.: I+type instance PF Expr = K Int :+: I :*: I :+: I :*: I instance Regular Expr where from (Const n) = L (K n)- from (e1 :++: e2) = R (L $ (I e1) :*: (I e2))- from (e1 :**: e2) = R (R (L $ (I e1) :*: (I e2)))- from (Fun s le) = R (R (R (K s :*: Comp (fmap I le))))+ from (e1 :++: e2) = R (L $ (I e1) :*: (I e2))+ from (e1 :**: e2) = R (R $ (I e1) :*: (I e2)) to (L (K n)) = Const n to (R (L ((I r1) :*: (I r2)))) = r1 :++: r2- to (R (R (L ((I r1) :*: (I r2))))) = r1 :**: r2- to (R (R (R (K s :*: Comp l)))) = Fun s (fmap unI l)- -data Nil-instance Constructor Nil where conName _ = "[]"-data Cons-instance Constructor Cons where conName _ = "(:)"--type instance PF1 [] = C Nil U :+: C Cons (I :*: []) -instance Regular1 [] where- from1 [] = L (C U)- from1 (h:t) = R (C (I h :*: t))- to1 (L (C U)) = []- to1 (R (C (I h :*: t))) = h : t+ to (R (R ((I r1) :*: (I r2)))) = r1 :**: r2 {- -- with Con type constructors to specify constructor names.@@ -52,13 +38,6 @@ -} instance Rewrite Expr-instance Crush [] where crush = dft_crush-instance GMap [] where fmapM = dft_fmapM-instance GShow [] where gshowf = dft_gshowf-instance Zip [] where fzipM = dft_fzipM-instance LR [] where- leftf = dft_leftf- rightf = dft_rightf ----------------------------------------------------------------------------- -- Example rules@@ -94,12 +73,7 @@ rule $ Const 1 :++: Const 1 :~> Const 2 -rule7 :: Rule Expr-rule7 = - rule $ \x -> Fun "square" [x] :~>- x :**: x - ----------------------------------------------------------------------------- -- Tests -----------------------------------------------------------------------------@@ -141,9 +115,6 @@ test11 :: Maybe Expr test11 = rewriteM rule6 (Const 1 :++: Const 1) -test12 :: Maybe Expr-test12 = rewriteM rule7 (Fun "square" [Const 3])- allTests :: [Maybe Expr] allTests = [ test1 , test2@@ -156,7 +127,6 @@ , test9 , test10 , test11- , test12 ]
rewriting.cabal view
@@ -1,5 +1,5 @@ name: rewriting-version: 0.2.1+version: 0.2.2 synopsis: Generic rewriting library for regular datatypes. description: @@ -18,7 +18,7 @@ <http://www.cs.uu.nl/wiki/GenericProgramming/Rewriting>. category: Generics-copyright: (c) 2009 Universiteit Utrecht+copyright: (c) 2012 Universiteit Utrecht license: BSD3 license-file: LICENSE author: Thomas van Noort,@@ -29,8 +29,8 @@ maintainer: generics@haskell.org stability: experimental build-type: Custom-cabal-version: >= 1.2.1-tested-with: GHC == 6.10.1+cabal-version: >= 1.6+tested-with: GHC == 6.10.1, GHC == 7.0.1, GHC == 7.4.1 extra-source-files: examples/expr/run examples/expr/Expr.hs examples/expr/Expr.expected@@ -40,7 +40,11 @@ examples/logic/LogicStrategies.hs examples/logic/run +source-repository head+ type: svn+ location: https://subversion.cs.uu.nl/repos/project.dgp-haskell.libraries/rewriting/trunk/ + -- Disabled the test flag for the moment since not all -- modules from the tests directory are properly included -- in the distribution generated by the sdist target@@ -60,7 +64,7 @@ Generics.Regular.Rewriting.Strategies build-depends: base >= 4.0 && < 5, containers >= 0.1,- regular >= 0.2 && < 0.3+ regular >= 0.2 && < 0.4 -- Disabled the test flag for the moment since not all -- modules from the tests directory are properly included