Maintainer | bastiaan.heeren@ou.nl |
---|---|
Stability | provisional |
Portability | portable (depends on ghc) |
Safe Haskell | Safe |
Language | Haskell98 |
A type class for expressing choice, preference, and left-biased choice.
The Menu
datatype implements the type class by keeping all the
alternatives.
- class Choice a where
- data Menu k a
- (|->) :: a -> s -> Menu a s
- doneMenu :: Menu k a
- eqMenuBy :: (k -> k -> Bool) -> (a -> a -> Bool) -> Menu k a -> Menu k a -> Bool
- elems :: Menu k a -> [(k, a)]
- bests :: Menu k a -> [(k, a)]
- bestsOrdered :: (k -> k -> Ordering) -> Menu k a -> [(k, a)]
- isEmpty :: Menu k a -> Bool
- hasDone :: Menu k a -> Bool
- getByIndex :: Int -> Menu k a -> Maybe (k, a)
- cut :: Menu k a -> Menu k a
- onMenu :: Choice b => (k -> a -> b) -> b -> Menu k a -> b
- onMenuWithIndex :: Choice b => (Int -> k -> a -> b) -> b -> Menu k a -> b
Choice type class
Menu data type
eqMenuBy :: (k -> k -> Bool) -> (a -> a -> Bool) -> Menu k a -> Menu k a -> Bool Source #
Equality with a comparison function for the elements
Queries
bests :: Menu k a -> [(k, a)] Source #
Returns only the best elements that are in the menu with respect to left-biased choices.
bestsOrdered :: (k -> k -> Ordering) -> Menu k a -> [(k, a)] Source #
Returns only the best elements that are in the menu, with a given ordering.