on master help sign in
Document Rel8.Table.Alternative
commit0b718acfbbfb0e2589c5be701bb4bd7859a47d15 authorOllie Charles <ollie@ocharles.org.uk> dateWed 24 Mar 2021, 11:39 (6 years ago) parenteb180fa
1 file changed+9
src/Rel8/Table/Alternative.hs+9
src/Rel8/Table/Alternative.hs+9
@@ -17,12 +17,21 @@ import Rel8.Expr ( Expr )
1717import Rel8.Table ( Table )
1818
1919
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.
2025type AltTable :: (Type -> Type) -> Constraint
2126class AltTable f where
27+ -- | An associative binary operation on 'Table's.
2228 (<|>:) :: Table Expr a => f a -> f a -> f a
2329 infixl 3 <|>:
2430
2531
32+-- | Like 'Alternative' in Haskell, some 'Table's form a monoid on applicative
33+-- functors.
2634type AlternativeTable :: (Type -> Type) -> Constraint
2735class AltTable f => AlternativeTable f where
36+ -- | The identity of '<|>:'.
2837 emptyTable :: Table Expr a => f a