miso
Copyright(C) 2016-2025 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Miso.Util

Description

 
Synopsis

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 #

enclosed :: Applicative f => f a -> f b -> f c -> f c Source #

optionalDefault :: Alternative f => b -> f b -> f b Source #

exists :: Alternative f => f a -> f Bool Source #

sepBy1 :: Alternative m => m sep -> m a -> m [a] Source #

sepBy :: Alternative m => m sep -> m a -> m [a] Source #

between :: Applicative f => f a -> f b -> f c -> f (b, c) Source #