| Copyright | (C) 2016-2025 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Miso.Util
Description
Synopsis
- withFoldable :: Foldable t => t a -> (a -> b) -> [b]
- conditionalViews :: Bool -> [view] -> [view]
- oneOf :: Alternative f => [f a] -> f a
- enclosed :: Applicative f => f a -> f b -> f c -> f c
- optionalDefault :: Alternative f => b -> f b -> f b
- exists :: Alternative f => f a -> f Bool
- sepBy1 :: Alternative m => m sep -> m a -> m [a]
- sepBy :: Alternative m => m sep -> m a -> m [a]
- between :: Applicative f => f a -> f b -> f c -> f (b, c)
- (=:) :: k -> v -> (k, v)
- compose :: Category cat => cat b c -> cat a b -> cat a c
Documentation
withFoldable :: Foldable t => t a -> (a -> b) -> [b] Source #
Generic map function, useful for creating Views from the elements of
some Foldable. Particularly handy for Maybe, as shown in the example
below.
view model =
div_ [] $
withFoldable (model ^. mSomeMaybeVal) $ \someVal ->
p_ [] [ text $ "Hey, look at this value: " <> ms (show someVal) ]
conditionalViews :: Bool -> [view] -> [view] Source #
Hides the Views if the condition is False. Shows them when the condition
is True.
oneOf :: Alternative f => [f a] -> f a Source #
Select the first Alternative, analogous to asum.
enclosed :: Applicative f => f a -> f b -> f c -> f c Source #
Convenience function for constructing parser / lexer combinators.
test :: Parser a -> Parser a
test = enclosed (char '(') (char ')')
optionalDefault :: Alternative f => b -> f b -> f b Source #
Allow the specification of default values during parsing / lexing in the case of parser / lexer failure.
test :: Parser MisoString test = optionalDefault "foo" (string "bar")
exists :: Alternative f => f a -> f Bool Source #
Combinator for testing parsing / lexing failure on any input.
test :: Parser Bool test = exists (string "foo")
sepBy1 :: Alternative m => m sep -> m a -> m [a] Source #
Interleaves one parser combinator with another, must have at least one successful parse.
test :: Parser [Int] test = sepBy1 (char ',') number
sepBy :: Alternative m => m sep -> m a -> m [a] Source #
Interleaves one parser combinator with another, may not have any successful parses.
test :: Parser [Int] test = sepBy (char ',') number
between :: Applicative f => f a -> f b -> f c -> f (b, c) Source #
Successfully parses the arguments between another combinator
test :: Parser (Int, Int)
test = between (char *) number number
-- 5*5