kure-2.18.6: Combinators for Strategic Programming
Copyright(c) 2012--2021 The University of Kansas
LicenseBSD3
MaintainerNeil Sculthorpe <neil.sculthorpe@ntu.ac.uk>
Stabilitybeta
Portabilityghc
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.KURE.Transform

Description

This module defines Transform and Rewrite, the main KURE types. Rewrite is just a special case of Transform, and so any function that operates on Transform is also applicable to Rewrite.

Transform is an instance of the Monad and Arrow type-class families, and consequently many of the desirable combinators over Transform and Rewrite are special cases of existing monadic or arrow combinators. Language.KURE.Combinators provides some additional combinators that aren't in the standard libraries.

Synopsis

Transformations and Rewrites

data Transform c m a b Source #

An abstract representation of a transformation from a value of type a in a context c to a monadic value of type m b. The Transform type is the basis of the entire KURE library.

Instances

Instances details
Monad m => Category (Transform c m :: Type -> Type -> Type) Source #

The Kleisli Category induced by m, lifting through a Reader transformer, where c is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

id :: forall (a :: k). Transform c m a a #

(.) :: forall (b :: k) (c0 :: k) (a :: k). Transform c m b c0 -> Transform c m a b -> Transform c m a c0 #

Monad m => Arrow (Transform c m) Source #

The Kleisli Arrow induced by m, lifting through a Reader transformer, where c is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

arr :: (b -> c0) -> Transform c m b c0 #

first :: Transform c m b c0 -> Transform c m (b, d) (c0, d) #

second :: Transform c m b c0 -> Transform c m (d, b) (d, c0) #

(***) :: Transform c m b c0 -> Transform c m b' c' -> Transform c m (b, b') (c0, c') #

(&&&) :: Transform c m b c0 -> Transform c m b c' -> Transform c m b (c0, c') #

MonadPlus m => ArrowZero (Transform c m) Source #

The Kleisli Arrow induced by m, lifting through a Reader transformer, where c is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

zeroArrow :: Transform c m b c0 #

MonadPlus m => ArrowPlus (Transform c m) Source #

The Kleisli Arrow induced by m, lifting through a Reader transformer, where c is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

(<+>) :: Transform c m b c0 -> Transform c m b c0 -> Transform c m b c0 #

Monad m => ArrowApply (Transform c m) Source #

The Kleisli Arrow induced by m, lifting through a Reader transformer, where c is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

app :: Transform c m (Transform c m b c0, b) c0 #

Monad m => Monad (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

(>>=) :: Transform c m a a0 -> (a0 -> Transform c m a b) -> Transform c m a b #

(>>) :: Transform c m a a0 -> Transform c m a b -> Transform c m a b #

return :: a0 -> Transform c m a a0 #

Functor m => Functor (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

fmap :: (a0 -> b) -> Transform c m a a0 -> Transform c m a b #

(<$) :: a0 -> Transform c m a b -> Transform c m a a0 #

MonadFail m => MonadFail (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

fail :: String -> Transform c m a a0 #

Applicative m => Applicative (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

pure :: a0 -> Transform c m a a0 #

(<*>) :: Transform c m a (a0 -> b) -> Transform c m a a0 -> Transform c m a b #

liftA2 :: (a0 -> b -> c0) -> Transform c m a a0 -> Transform c m a b -> Transform c m a c0 #

(*>) :: Transform c m a a0 -> Transform c m a b -> Transform c m a b #

(<*) :: Transform c m a a0 -> Transform c m a b -> Transform c m a a0 #

MonadIO m => MonadIO (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

liftIO :: IO a0 -> Transform c m a a0 #

Alternative m => Alternative (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

empty :: Transform c m a a0 #

(<|>) :: Transform c m a a0 -> Transform c m a a0 -> Transform c m a a0 #

some :: Transform c m a a0 -> Transform c m a [a0] #

many :: Transform c m a a0 -> Transform c m a [a0] #

MonadPlus m => MonadPlus (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

mzero :: Transform c m a a0 #

mplus :: Transform c m a a0 -> Transform c m a a0 -> Transform c m a a0 #

MonadCatch m => MonadCatch (Transform c m a) Source #

Lifting through a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

catchM :: Transform c m a a0 -> (String -> Transform c m a a0) -> Transform c m a a0 Source #

(Applicative m, Semigroup b) => Semigroup (Transform c m a b) Source #

Lifting through the Monad and a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

(<>) :: Transform c m a b -> Transform c m a b -> Transform c m a b #

sconcat :: NonEmpty (Transform c m a b) -> Transform c m a b #

stimes :: Integral b0 => b0 -> Transform c m a b -> Transform c m a b #

(Monad m, Monoid b) => Monoid (Transform c m a b) Source #

Lifting through the Monad and a Reader transformer, where (c,a) is the read-only environment.

Instance details

Defined in Language.KURE.Transform

Methods

mempty :: Transform c m a b #

mappend :: Transform c m a b -> Transform c m a b -> Transform c m a b #

mconcat :: [Transform c m a b] -> Transform c m a b #

type Translate c m a b = Transform c m a b Source #

A deprecated synonym for Transform.

type Rewrite c m a = Transform c m a a Source #

A transformation that shares the same source and target type.

applyT :: Transform c m a b -> c -> a -> m b Source #

Apply a transformation to a value and its context.

applyR :: Rewrite c m a -> c -> a -> m a Source #

Apply a rewrite to a value and its context.

apply :: Transform c m a b -> c -> a -> m b Source #

Deprecated: Please use applyT instead.

A deprecated synonym for applyT.

transform :: (c -> a -> m b) -> Transform c m a b Source #

The primitive way of building a transformation.

translate :: (c -> a -> m b) -> Translate c m a b Source #

Deprecated: Please use transform instead.

A deprecated synonym for transform.

rewrite :: (c -> a -> m a) -> Rewrite c m a Source #

The primitive way of building a rewrite.

contextfreeT :: (a -> m b) -> Transform c m a b Source #

Build a Transform that doesn't depend on the context.

contextonlyT :: (c -> m b) -> Transform c m a b Source #

Build a Transform that doesn't depend on the value.

constT :: m b -> Transform c m a b Source #

Build a constant Transform from a monadic computation.

effectfreeT :: Monad m => (c -> a -> b) -> Transform c m a b Source #

Build a Transform that doesn't perform any monadic effects.