on master help sign in
Document Rel8.Table.Alternative
0b718acOllie Charles
src/Rel8/Table/Alternative.hs+9
@@ -17,12 +17,21 @@ import Rel8.Expr ( Expr )
17import Rel8.Table ( Table )
17import Rel8.Table ( Table )
18
18
19
19
20+-- | Like 'Alt' in Haskell. This class is purely a Rel8 concept, and allows you
21+-- to take a choice between two tables. See also 'AlternativeTable'.
22+--
23+-- For example, using '<|>:' on 'MaybeTable' allows you to combine two tables
24+-- and to return the first one that is a "just" MaybeTable.
20type AltTable :: (Type -> Type) -> Constraint
25type AltTable :: (Type -> Type) -> Constraint
21class AltTable f where
26class AltTable f where
27+ -- | An associative binary operation on 'Table's.
22 (<|>:) :: Table Expr a => f a -> f a -> f a
28 (<|>:) :: Table Expr a => f a -> f a -> f a
23 infixl 3 <|>:
29 infixl 3 <|>:
24
30
25
31
32+-- | Like 'Alternative' in Haskell, some 'Table's form a monoid on applicative
33+-- functors.
26type AlternativeTable :: (Type -> Type) -> Constraint
34type AlternativeTable :: (Type -> Type) -> Constraint
27class AltTable f => AlternativeTable f where
35class AltTable f => AlternativeTable f where
36+ -- | The identity of '<|>:'.
28 emptyTable :: Table Expr a => f a
37 emptyTable :: Table Expr a => f a