hxt-9.3.1.22: A collection of tools for processing XML with Haskell.

Copyright | Copyright (C) 2005 Uwe Schmidt
License | MIT
Maintainer | Uwe Schmidt (uwe\@fh-wedel.de)
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Control.Arrow.ArrowIf

Description

Conditionals for List Arrows

This module defines conditional combinators for list arrows.

The empty list as result represents False, none empty lists True.

Synopsis

- class ArrowList a => ArrowIf (a :: Type -> Type -> Type) where
  - ifA :: a b c -> a b d -> a b d -> a b d
  - ifP :: (b -> Bool) -> a b d -> a b d -> a b d
  - neg :: a b c -> a b b
  - when :: a b b -> a b c -> a b b
  - whenP :: a b b -> (b -> Bool) -> a b b
  - whenNot :: a b b -> a b c -> a b b
  - whenNotP :: a b b -> (b -> Bool) -> a b b
  - guards :: a b c -> a b d -> a b d
  - guardsP :: (b -> Bool) -> a b d -> a b d
  - filterA :: a b c -> a b b
  - containing :: a b c -> a c d -> a b c
  - notContaining :: a b c -> a c d -> a b c
  - orElse :: a b c -> a b c -> a b c
  - choiceA :: [IfThen (a b c) (a b d)] -> a b d
  - tagA :: a b c -> a b (Either b b)
  - spanA :: a b b -> a [b] ([b], [b])
  - partitionA :: a b b -> a [b] ([b], [b])
- data IfThen a b = a :-> b

# Documentation

class ArrowList a => ArrowIf (a :: Type -> Type -> Type) where #

The interface for arrows as conditionals.

Requires list arrows because False is represented as empty list, True as none empty lists.

Only `ifA` and `orElse` don't have default implementations

Minimal complete definition

ifA, orElse

Methods

ifA :: a b c -> a b d -> a b d -> a b d #

if lifted to arrows

ifP :: (b -> Bool) -> a b d -> a b d -> a b d #

shortcut: `ifP p = ifA (isA p)`

neg :: a b c -> a b b #

negation: `neg f = ifA f none this`

when :: a b b -> a b c -> a b b #

`f `when` g` : when the predicate g holds, f is applied, else the identity filter this

whenP :: a b b -> (b -> Bool) -> a b b #

shortcut: `f `whenP` p = f `when` (isA p)`

whenNot :: a b b -> a b c -> a b b #

`f `whenNot` g` : when the predicate g does not hold, f is applied, else the identity filter this

whenNotP :: a b b -> (b -> Bool) -> a b b #

like `whenP`

guards :: a b c -> a b d -> a b d #

`g `guards` f` : when the predicate g holds, f is applied, else none

guardsP :: (b -> Bool) -> a b d -> a b d #

like `whenP`

filterA :: a b c -> a b b #

shortcut for `f `guards` this`

containing :: a b c -> a c d -> a b c #

`f `containing` g` : keep only those results from f for which g holds

definition: `f `containing` g = f >>> g `guards` this`

notContaining :: a b c -> a c d -> a b c #

`f `notContaining` g` : keep only those results from f for which g does not hold

definition: `f `notContaining` g = f >>> ifA g none this`

orElse :: a b c -> a b c -> a b c #

`f `orElse` g` : directional choice: if f succeeds, the result of f is the result, else g is applied

choiceA :: [IfThen (a b c) (a b d)] -> a b d #

generalisation of `orElse` for multi way branches like in case expressions.

An auxiliary data type `IfThen` with an infix constructor `:->` is used for writing multi way branches

example: `choiceA [ p1 :-> e1, p2 :-> e2, this :-> default ]`

tagA :: a b c -> a b (Either b b) #

tag a value with Left or Right, if arrow has success, input is tagged with Left, else with Right

spanA :: a b b -> a [b] ([b], [b]) #

split a list value with an arrow and returns a pair of lists. This is the arrow version of `span`. The arrow is deterministic.

example: `runLA (spanA (isA (/= '-'))) "abc-def"` gives `[("abc","-def")]` as result

partitionA :: a b b -> a [b] ([b], [b]) #

partition a list of values into a pair of lists

This is the arrow Version of `partition`

#### Instances

Instances details

ArrowIf IOLA # |

Instance details

Defined in Control.Arrow.IOListArrow

Methods

ifA :: IOLA b c -> IOLA b d -> IOLA b d -> IOLA b d #

ifP :: (b -> Bool) -> IOLA b d -> IOLA b d -> IOLA b d #

neg :: IOLA b c -> IOLA b b #

when :: IOLA b b -> IOLA b c -> IOLA b b #

whenP :: IOLA b b -> (b -> Bool) -> IOLA b b #

whenNot :: IOLA b b -> IOLA b c -> IOLA b b #

whenNotP :: IOLA b b -> (b -> Bool) -> IOLA b b #

guards :: IOLA b c -> IOLA b d -> IOLA b d #

guardsP :: (b -> Bool) -> IOLA b d -> IOLA b d #

filterA :: IOLA b c -> IOLA b b #

containing :: IOLA b c -> IOLA c d -> IOLA b c #

notContaining :: IOLA b c -> IOLA c d -> IOLA b c #

orElse :: IOLA b c -> IOLA b c -> IOLA b c #

choiceA :: [IfThen (IOLA b c) (IOLA b d)] -> IOLA b d #

tagA :: IOLA b c -> IOLA b (Either b b) #

spanA :: IOLA b b -> IOLA [b] ([b], [b]) #

partitionA :: IOLA b b -> IOLA [b] ([b], [b]) #

ArrowIf LA # |

Instance details

Defined in Control.Arrow.ListArrow

Methods

ifA :: LA b c -> LA b d -> LA b d -> LA b d #

ifP :: (b -> Bool) -> LA b d -> LA b d -> LA b d #

neg :: LA b c -> LA b b #

when :: LA b b -> LA b c -> LA b b #

whenP :: LA b b -> (b -> Bool) -> LA b b #

whenNot :: LA b b -> LA b c -> LA b b #

whenNotP :: LA b b -> (b -> Bool) -> LA b b #

guards :: LA b c -> LA b d -> LA b d #

guardsP :: (b -> Bool) -> LA b d -> LA b d #

filterA :: LA b c -> LA b b #

containing :: LA b c -> LA c d -> LA b c #

notContaining :: LA b c -> LA c d -> LA b c #

orElse :: LA b c -> LA b c -> LA b c #

choiceA :: [IfThen (LA b c) (LA b d)] -> LA b d #

tagA :: LA b c -> LA b (Either b b) #

spanA :: LA b b -> LA [b] ([b], [b]) #

partitionA :: LA b b -> LA [b] ([b], [b]) #

ArrowIf (IOSLA s) # |

Instance details

Defined in Control.Arrow.IOStateListArrow

Methods

ifA :: IOSLA s b c -> IOSLA s b d -> IOSLA s b d -> IOSLA s b d #

ifP :: (b -> Bool) -> IOSLA s b d -> IOSLA s b d -> IOSLA s b d #

neg :: IOSLA s b c -> IOSLA s b b #

when :: IOSLA s b b -> IOSLA s b c -> IOSLA s b b #

whenP :: IOSLA s b b -> (b -> Bool) -> IOSLA s b b #

whenNot :: IOSLA s b b -> IOSLA s b c -> IOSLA s b b #

whenNotP :: IOSLA s b b -> (b -> Bool) -> IOSLA s b b #

guards :: IOSLA s b c -> IOSLA s b d -> IOSLA s b d #

guardsP :: (b -> Bool) -> IOSLA s b d -> IOSLA s b d #

filterA :: IOSLA s b c -> IOSLA s b b #

containing :: IOSLA s b c -> IOSLA s c d -> IOSLA s b c #

notContaining :: IOSLA s b c -> IOSLA s c d -> IOSLA s b c #

orElse :: IOSLA s b c -> IOSLA s b c -> IOSLA s b c #

choiceA :: [IfThen (IOSLA s b c) (IOSLA s b d)] -> IOSLA s b d #

tagA :: IOSLA s b c -> IOSLA s b (Either b b) #

spanA :: IOSLA s b b -> IOSLA s [b] ([b], [b]) #

partitionA :: IOSLA s b b -> IOSLA s [b] ([b], [b]) #

ArrowIf (SLA s) # |

Instance details

Defined in Control.Arrow.StateListArrow

Methods

ifA :: SLA s b c -> SLA s b d -> SLA s b d -> SLA s b d #

ifP :: (b -> Bool) -> SLA s b d -> SLA s b d -> SLA s b d #

neg :: SLA s b c -> SLA s b b #

when :: SLA s b b -> SLA s b c -> SLA s b b #

whenP :: SLA s b b -> (b -> Bool) -> SLA s b b #

whenNot :: SLA s b b -> SLA s b c -> SLA s b b #

whenNotP :: SLA s b b -> (b -> Bool) -> SLA s b b #

guards :: SLA s b c -> SLA s b d -> SLA s b d #

guardsP :: (b -> Bool) -> SLA s b d -> SLA s b d #

filterA :: SLA s b c -> SLA s b b #

containing :: SLA s b c -> SLA s c d -> SLA s b c #

notContaining :: SLA s b c -> SLA s c d -> SLA s b c #

orElse :: SLA s b c -> SLA s b c -> SLA s b c #

choiceA :: [IfThen (SLA s b c) (SLA s b d)] -> SLA s b d #

tagA :: SLA s b c -> SLA s b (Either b b) #

spanA :: SLA s b b -> SLA s [b] ([b], [b]) #

partitionA :: SLA s b b -> SLA s [b] ([b], [b]) #

data IfThen a b #

an auxiliary data type for `choiceA`

Constructors

a :-> b |