kure 2.14.0 → 2.14.4
raw patch · 4 files changed
+81/−4 lines, 4 files
Files
- Language/KURE/Combinators/Translate.hs +34/−1
- Language/KURE/MonadCatch.hs +2/−1
- Language/KURE/Walker.hs +43/−0
- kure.cabal +2/−2
Language/KURE/Combinators/Translate.hs view
@@ -51,7 +51,8 @@ import Prelude hiding (id, map, foldr, mapM) import Control.Category ((>>>),id)-import Control.Monad (liftM)+import Control.Applicative+import Control.Monad (liftM,ap) import Data.Foldable import Data.Traversable@@ -181,6 +182,10 @@ data PBool a = PBool !Bool a +instance Functor PBool where+ fmap :: (a -> b) -> PBool a -> PBool b+ fmap f (PBool b a) = PBool b (f a)+ checkSuccessPBool :: Monad m => String -> m (PBool a) -> m a checkSuccessPBool msg m = do PBool b a <- m if b@@ -203,6 +208,20 @@ unAnyR (AnyR mba) = mba {-# INLINE unAnyR #-} +instance Monad m => Functor (AnyR m) where+ fmap :: (a -> b) -> AnyR m a -> AnyR m b+ fmap = liftM+ {-# INLINE fmap #-}++instance Monad m => Applicative (AnyR m) where+ pure :: a -> AnyR m a+ pure = return+ {-# INLINE pure #-}++ (<*>) :: AnyR m (a -> b) -> AnyR m a -> AnyR m b+ (<*>) = ap+ {-# INLINE (<*>) #-}+ instance Monad m => Monad (AnyR m) where return :: a -> AnyR m a return = AnyR . return . PBool False@@ -247,6 +266,20 @@ unOneR :: OneR m a -> Bool -> m (PBool a) unOneR (OneR mba) = mba {-# INLINE unOneR #-}++instance Monad m => Functor (OneR m) where+ fmap :: (a -> b) -> OneR m a -> OneR m b+ fmap = liftM+ {-# INLINE fmap #-}++instance Monad m => Applicative (OneR m) where+ pure :: a -> OneR m a+ pure = return+ {-# INLINE pure #-}++ (<*>) :: OneR m (a -> b) -> OneR m a -> OneR m b+ (<*>) = ap+ {-# INLINE (<*>) #-} instance Monad m => Monad (OneR m) where return :: a -> OneR m a
Language/KURE/MonadCatch.hs view
@@ -52,9 +52,10 @@ ------------------------------------------------------------------------------------------ -- | 'Monad's with a catch for 'fail'.--- The following law is expected to hold:+-- The following laws are expected to hold: -- -- > fail msg `catchM` f == f msg+-- > return a `catchM` f == return a class Monad m => MonadCatch m where -- | Catch a failing monadic computation.
Language/KURE/Walker.hs view
@@ -79,6 +79,7 @@ import Data.DList (singleton, toList) import Control.Monad+import Control.Applicative import Control.Arrow import Control.Category hiding ((.)) @@ -402,6 +403,20 @@ unAllT (AllT mw) = mw {-# INLINE unAllT #-} +instance (Monoid w, Monad m) => Functor (AllT w m) where+ fmap :: (a -> b) -> AllT w m a -> AllT w m b+ fmap = liftM+ {-# INLINE fmap #-}++instance (Monoid w, Monad m) => Applicative (AllT w m) where+ pure :: a -> AllT w m a+ pure = return+ {-# INLINE pure #-}++ (<*>) :: AllT w m (a -> b) -> AllT w m a -> AllT w m b+ (<*>) = ap+ {-# INLINE (<*>) #-}+ instance (Monoid w, Monad m) => Monad (AllT w m) where return :: a -> AllT w m a return a = AllT $ return (P a mempty)@@ -446,6 +461,20 @@ unOneT (OneT f) = f {-# INLINE unOneT #-} +instance (Monoid w, Monad m) => Functor (OneT w m) where+ fmap :: (a -> b) -> OneT w m a -> OneT w m b+ fmap = liftM+ {-# INLINE fmap #-}++instance (Monoid w, Monad m) => Applicative (OneT w m) where+ pure :: a -> OneT w m a+ pure = return+ {-# INLINE pure #-}++ (<*>) :: OneT w m (a -> b) -> OneT w m a -> OneT w m b+ (<*>) = ap+ {-# INLINE (<*>) #-}+ instance Monad m => Monad (OneT w m) where return :: a -> OneT w m a return a = OneT $ \ mw -> return (P a mw)@@ -491,6 +520,20 @@ getChildSecond :: (Maybe (c,g) -> Maybe (c,g)) -> GetChild c g a -> GetChild c g a getChildSecond f (GetChild ka mcg) = GetChild ka (f mcg) {-# INLINE getChildSecond #-}++instance Functor (GetChild c g) where+ fmap :: (a -> b) -> GetChild c g a -> GetChild c g b+ fmap = liftM+ {-# INLINE fmap #-}++instance Applicative (GetChild c g) where+ pure :: a -> GetChild c g a+ pure = return+ {-# INLINE pure #-}++ (<*>) :: GetChild c g (a -> b) -> GetChild c g a -> GetChild c g b+ (<*>) = ap+ {-# INLINE (<*>) #-} instance Monad (GetChild c g) where return :: a -> GetChild c g a
kure.cabal view
@@ -1,5 +1,5 @@ Name: kure-Version: 2.14.0+Version: 2.14.4 Synopsis: Combinators for Strategic Programming 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.@@ -11,7 +11,7 @@ . 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.+ The Kansas University Rewrite Engine: A Haskell-Embedded Strategic Programming Language with Custom Closed Universes. Neil Sculthorpe, Nicolas Frisby and Andy Gill. 2013. <http://www.ittc.ku.edu/~neil/papers_and_talks/kure.pdf> Category: Language