<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >Control.Arrow.ArrowIf</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_Control-Arrow-ArrowIf.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >hxt-8.3.2: A collection of tools for processing XML with Haskell.</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >Control.Arrow.ArrowIf</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >portable</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >experimental</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >Uwe Schmidt (uwe\@fh-wedel.de)</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" ><P >Version : $Id: ArrowIf.hs,v 1.8 2006<EM >05</EM >04 14:17:53 hxml Exp $ </P ><P >Conditionals for List Arrows </P ><P >This module defines conditional combinators for list arrows. </P ><P >The empty list as result represents False, none empty lists True. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >class</SPAN > <A HREF="Control-Arrow-ArrowList.html#t%3AArrowList" >ArrowList</A > a => <A HREF="#t%3AArrowIf" >ArrowIf</A > a <SPAN CLASS="keyword" >where</SPAN ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="#v%3AifA" >ifA</A > :: a b c -> a b d -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AifP" >ifP</A > :: (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b d -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aneg" >neg</A > :: a b c -> a b b</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Awhen" >when</A > :: a b b -> a b c -> a b b</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AwhenP" >whenP</A > :: a b b -> (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b b</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AwhenNot" >whenNot</A > :: a b b -> a b c -> a b b</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AwhenNotP" >whenNotP</A > :: a b b -> (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b b</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aguards" >guards</A > :: a b c -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AguardsP" >guardsP</A > :: (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AfilterA" >filterA</A > :: a b c -> a b b</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Acontaining" >containing</A > :: a b c -> a c d -> a b c</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnotContaining" >notContaining</A > :: a b c -> a c d -> a b c</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AorElse" >orElse</A > :: a b c -> a b c -> a b c</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AchoiceA" >choiceA</A > :: [<A HREF="Control-Arrow-ArrowIf.html#t%3AIfThen" >IfThen</A > (a b c) (a b d)] -> a b d</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtagA" >tagA</A > :: a b c -> a b (<A HREF="/usr/share/doc/ghc/libraries/base/Data-Either.html#t%3AEither" >Either</A > b b)</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AspanA" >spanA</A > :: a b b -> a [b] ([b], [b])</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ApartitionA" >partitionA</A > :: a b b -> a [b] ([b], [b])</TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AIfThen" >IfThen</A > a b = a <A HREF="#v%3A%3A-%3E" >:-></A > b</TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Documentation</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >class</SPAN > <A HREF="Control-Arrow-ArrowList.html#t%3AArrowList" >ArrowList</A > a => <A NAME="t:ArrowIf" ><A NAME="t%3AArrowIf" ></A ></A ><B >ArrowIf</B > a <SPAN CLASS="keyword" >where</SPAN ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" ><P >The interface for arrows as conditionals. </P ><P >Requires list arrows because False is represented as empty list, True as none empty lists. </P ><P >Only <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3AifA" >ifA</A ></TT > and <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3AorElse" >orElse</A ></TT > don't have default implementations </P ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="section4" >Methods</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A NAME="v:ifA" ><A NAME="v%3AifA" ></A ></A ><B >ifA</B > :: a b c -> a b d -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="doc" >if lifted to arrows </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:ifP" ><A NAME="v%3AifP" ></A ></A ><B >ifP</B > :: (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b d -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="doc" >shortcut: <TT > ifP p = ifA (isA p) </TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:neg" ><A NAME="v%3Aneg" ></A ></A ><B >neg</B > :: a b c -> a b b</TD ></TR ><TR ><TD CLASS="doc" >negation: <TT > neg f = ifA f none this </TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:when" ><A NAME="v%3Awhen" ></A ></A ><B >when</B > :: a b b -> a b c -> a b b</TD ></TR ><TR ><TD CLASS="doc" ><TT > f `when` g </TT > : when the predicate g holds, f is applied, else the identity filter this </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:whenP" ><A NAME="v%3AwhenP" ></A ></A ><B >whenP</B > :: a b b -> (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b b</TD ></TR ><TR ><TD CLASS="doc" >shortcut: <TT > f `whenP` p = f `when` (isA p) </TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:whenNot" ><A NAME="v%3AwhenNot" ></A ></A ><B >whenNot</B > :: a b b -> a b c -> a b b</TD ></TR ><TR ><TD CLASS="doc" ><TT > f `whenNot` g </TT > : when the predicate g does not hold, f is applied, else the identity filter this </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:whenNotP" ><A NAME="v%3AwhenNotP" ></A ></A ><B >whenNotP</B > :: a b b -> (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b b</TD ></TR ><TR ><TD CLASS="doc" >like <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3AwhenP" >whenP</A ></TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:guards" ><A NAME="v%3Aguards" ></A ></A ><B >guards</B > :: a b c -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="doc" ><TT > g `guards` f </TT > : when the predicate g holds, f is applied, else none </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:guardsP" ><A NAME="v%3AguardsP" ></A ></A ><B >guardsP</B > :: (b -> <A HREF="/usr/share/doc/ghc/libraries/ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A >) -> a b d -> a b d</TD ></TR ><TR ><TD CLASS="doc" >like <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3AwhenP" >whenP</A ></TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:filterA" ><A NAME="v%3AfilterA" ></A ></A ><B >filterA</B > :: a b c -> a b b</TD ></TR ><TR ><TD CLASS="doc" >shortcut for <TT > f <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3Aguards" >guards</A ></TT > this </TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:containing" ><A NAME="v%3Acontaining" ></A ></A ><B >containing</B > :: a b c -> a c d -> a b c</TD ></TR ><TR ><TD CLASS="doc" ><P ><TT > f `containing` g </TT > : keep only those results from f for which g holds </P ><P >definition: <TT > f `containing` g = f >>> g `guards` this </TT > </P ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:notContaining" ><A NAME="v%3AnotContaining" ></A ></A ><B >notContaining</B > :: a b c -> a c d -> a b c</TD ></TR ><TR ><TD CLASS="doc" ><P ><TT > f `notContaining` g </TT > : keep only those results from f for which g does not hold </P ><P >definition: <TT > f `notContaining` g = f >>> ifA g none this </TT > </P ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:orElse" ><A NAME="v%3AorElse" ></A ></A ><B >orElse</B > :: a b c -> a b c -> a b c</TD ></TR ><TR ><TD CLASS="doc" ><TT > f `orElse` g </TT > : directional choice: if f succeeds, the result of f is the result, else g is applied </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:choiceA" ><A NAME="v%3AchoiceA" ></A ></A ><B >choiceA</B > :: [<A HREF="Control-Arrow-ArrowIf.html#t%3AIfThen" >IfThen</A > (a b c) (a b d)] -> a b d</TD ></TR ><TR ><TD CLASS="doc" ><P >generalisation of <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3AorElse" >orElse</A ></TT > for multi way branches like in case expressions. </P ><P >An auxiliary data type <TT ><A HREF="Control-Arrow-ArrowIf.html#t%3AIfThen" >IfThen</A ></TT > with an infix constructor ':->' is used for writing multi way branches </P ><P >example: <TT > choiceA [ p1 :-> e1, p2 :-> e2, this :-> default ] </TT > </P ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:tagA" ><A NAME="v%3AtagA" ></A ></A ><B >tagA</B > :: a b c -> a b (<A HREF="/usr/share/doc/ghc/libraries/base/Data-Either.html#t%3AEither" >Either</A > b b)</TD ></TR ><TR ><TD CLASS="doc" >tag a value with Left or Right, if arrow has success, input is tagged with Left, else with Right </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:spanA" ><A NAME="v%3AspanA" ></A ></A ><B >spanA</B > :: a b b -> a [b] ([b], [b])</TD ></TR ><TR ><TD CLASS="doc" ><P >split a list value with an arrow and returns a pair of lists. This is the arrow version of <TT ><A HREF="/usr/share/doc/ghc/libraries/base/Data-List.html#v%3Aspan" >span</A ></TT >. The arrow is deterministic. </P ><P >example: <TT > runLA (spanA (isA (/= '-'))) "abc-def" </TT > gives <TT > [("abc","-def")] </TT > as result </P ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:partitionA" ><A NAME="v%3ApartitionA" ></A ></A ><B >partitionA</B > :: a b b -> a [b] ([b], [b])</TD ></TR ><TR ><TD CLASS="doc" ><P >partition a list of values into a pair of lists </P ><P >This is the arrow Version of <TT ><A HREF="/usr/share/doc/ghc/libraries/base/Data-List.html#v%3Apartition" >partition</A ></TT > </P ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ArrowIf')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:ArrowIf" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Control-Arrow-ArrowIf.html#t%3AArrowIf" >ArrowIf</A > <A HREF="Control-Arrow-ListArrow.html#t%3ALA" >LA</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Arrow-ArrowIf.html#t%3AArrowIf" >ArrowIf</A > <A HREF="Control-Arrow-IOListArrow.html#t%3AIOLA" >IOLA</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Arrow-ArrowIf.html#t%3AArrowIf" >ArrowIf</A > (<A HREF="Control-Arrow-StateListArrow.html#t%3ASLA" >SLA</A > s)</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Arrow-ArrowIf.html#t%3AArrowIf" >ArrowIf</A > (<A HREF="Control-Arrow-IOStateListArrow.html#t%3AIOSLA" >IOSLA</A > s)</TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:IfThen" ><A NAME="t%3AIfThen" ></A ></A ><B >IfThen</B > a b </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >an auxiliary data type for <TT ><A HREF="Control-Arrow-ArrowIf.html#v%3AchoiceA" >choiceA</A ></TT > </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" >a <A NAME="v::->" ><A NAME="v%3A%3A-%3E" ></A ></A ><B >:-></B > b</TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.5.0</TD ></TR ></TABLE ></BODY ></HTML >