packages feed

kure 2.6.14 → 2.6.22

raw patch · 6 files changed

+40/−16 lines, 6 filesdep +dlist

Dependencies added: dlist

Files

Language/KURE/BiTranslate.hs view
@@ -7,7 +7,7 @@ -- Stability: beta -- Portability: ghc ----- A bi-directional translation is a tranlsation that can be applied in either direction.+-- A bi-directional translation is a translation that can be applied in either direction.  module Language.KURE.BiTranslate        (  -- * Bi-directional Translations@@ -17,7 +17,8 @@         , forewardT         , backwardT         , whicheverR-        , invert+        , invertBiT+        , beforeBiR ) where  import Prelude hiding (id, (.))@@ -49,9 +50,9 @@ {-# INLINE whicheverR #-}  -- | Invert the forewards and backwards directions of a 'BiTranslate'.-invert :: BiTranslate c m a b -> BiTranslate c m b a-invert (BiTranslate t1 t2) = BiTranslate t2 t1-{-# INLINE invert #-}+invertBiT :: BiTranslate c m a b -> BiTranslate c m b a+invertBiT (BiTranslate t1 t2) = BiTranslate t2 t1+{-# INLINE invertBiT #-}  instance Monad m => Category (BiTranslate c m) where -- id :: BiTranslate c m a a@@ -61,5 +62,11 @@ -- (.) :: BiTranslate c m b d -> BiTranslate c m a b -> BiTranslate c m a d    (BiTranslate f1 b1) . (BiTranslate f2 b2) = BiTranslate (f1 . f2) (b2 . b1)    {-# INLINE (.) #-}+++-- | Perform the argument translation before /either/ direction of the bidirectional rewrite.+beforeBiR :: Monad m => Translate c m a b -> (b -> BiRewrite c m a) -> BiRewrite c m a+beforeBiR t f = bidirectional (t >>= (forewardT . f)) (t >>= (backwardT . f))+{-# INLINE beforeBiR #-}  ------------------------------------------------------------------------------------------
Language/KURE/Combinators/Monad.hs view
@@ -13,6 +13,7 @@            ( -- * Monadic Conditionals              guardMsg            , guardM+           , guardMsgM            , ifM            , whenM            , unlessM@@ -31,6 +32,12 @@ guardM ::  Monad m => Bool -> m () guardM b = guardMsg b "guardM failed" {-# INLINE guardM #-}++-- | As 'guardMsg', but with an @m Bool@ as argument.+guardMsgM :: Monad m => m Bool -> String -> m ()+guardMsgM mb msg = do b <- mb+                      guardMsg b msg+{-# INLINE guardMsgM #-}  -- | if-then-else lifted over a monadic predicate. ifM ::  Monad m => m Bool -> m a -> m a -> m a
Language/KURE/Translate.hs view
@@ -166,6 +166,10 @@    first t = translate $ \ c (a,z) -> liftM (\ b -> (b,z)) (apply t c a)    {-# INLINE first #-} +-- second :: Translate c m a b -> Translate c m (z,a) (z,b)+   second t = translate $ \ c (z,a) -> liftM (\ b -> (z,b)) (apply t c a)+   {-# INLINE second #-}+ -- (***) :: Translate c m a1 b1 -> Translate c m a2 b2 -> Translate c m (a1,a2) (b1,b2)    t1 *** t2 = translate $ \ c (a,b) -> liftM2 (,) (apply t1 c a) (apply t2 c b)    {-# INLINE (***) #-}
Language/KURE/Walker.hs view
@@ -95,6 +95,7 @@ import Data.Maybe (isJust) import Data.Monoid import Data.List+import Data.DList (singleton, toList)  import Control.Monad import Control.Arrow@@ -222,12 +223,12 @@  -- | An always successful traversal that collects the results of all successful applications of a 'Translate' in a list. collectT :: (Walker c g, MonadCatch m) => Translate c m g b -> Translate c m g [b]-collectT t = crushtdT (t >>^ return)+collectT t = crushtdT (t >>^ singleton) >>^ toList {-# INLINE collectT #-}  -- | Like 'collectT', but does not traverse below successes. collectPruneT :: (Walker c g, MonadCatch m) => Translate c m g b -> Translate c m g [b]-collectPruneT t = prunetdT (t >>^ return)+collectPruneT t = prunetdT (t >>^ singleton) >>^ toList {-# INLINE collectPruneT #-}  -------------------------------------------------------------------------------
examples/Fib/Examples.hs view
@@ -13,7 +13,7 @@  ----------------------------------------------------------------------- -applyFib :: RewriteA -> Arith -> Either String Arith+applyFib :: TranslateA b -> Arith -> Either String b applyFib r = runKureM Right Left . apply r rootAbsPath  -----------------------------------------------------------------------
kure.cabal view
@@ -1,14 +1,18 @@ Name:                kure-Version:             2.6.14+Version:             2.6.22 Synopsis:            Combinators for Strategic Programming-Description:	     The Kansas University Rewrite Engine (KURE) is a DSL for strategic rewriting.-	 	     KURE shares concepts with Stratego, but unlike Stratego, KURE is strongly typed.-		     KURE is similar to StrategyLib, but has a lightweight generic traversal mechanism-                     using type families rather than SYB.+Description:	     The Kansas University Rewrite Engine (KURE) is a domain-specific language for strategic rewriting.+	 	     KURE was inspired by Stratego and StrategyLib, and has similarities with Scrap Your Boilerplate and Uniplate.+                     .                      The basic transformation functionality can be found in "Language.KURE.Translate",                      and the traversal functionality can be found in "Language.KURE.Walker".                      Several basic examples of using KURE are provided in the source-code bundle.-                     For a larger example, see the HERMIT package.+                     For larger examples, see the HERMIT or HTML-KURE packages.+                     .+                     You can read about KURE in the following article:+                     .+                     KURE: A Haskell-Embedded Strategic Programming Language with Custom Closed Universes.  Neil Sculthorpe and Nicolas Frisby and Andy Gill.  2013.+                     <http://www.ittc.ku.edu/~neil/papers_and_talks/kure.pdf>  Category:            Language License:             BSD3@@ -16,7 +20,7 @@ Author:              Neil Sculthorpe and Andy Gill Maintainer:          Neil Sculthorpe <neil@ittc.ku.edu> Copyright:           (c) 2012--2013 The University of Kansas-Homepage:            http://www.ittc.ku.edu/csdl/fpg/Tools/KURE+Homepage:            http://www.ittc.ku.edu/csdl/fpg/software/kure.html Stability:	     beta build-type: 	     Simple Cabal-Version:       >= 1.6@@ -33,7 +37,8 @@     examples/Expr/Examples.hs  Library-  Build-Depends: base >= 4.5 && < 5+  Build-Depends: base >= 4.5 && < 5,+                 dlist >= 0.2 && < 1   Ghc-Options: -Wall   Exposed-modules:        Language.KURE