hermit-0.7.1.0: Haskell Equational Reasoning Model-to-Implementation Tunnel

Safe HaskellSafe-Inferred
LanguageHaskell2010

HERMIT.Utilities

Contents

Synopsis

Utilities

nodups :: Eq a => [a] -> Bool Source

Determine if a list contains no duplicated elements.

dups :: Eq a => [a] -> [a] Source

Discard the last occurrence of each element in the list. Thus the returned list contains only the duplicated elements.

dupsBy :: (a -> a -> Bool) -> [a] -> [a] Source

Generalisation of dups to an arbitrary equality predicate.

soleElement :: Monad m => [a] -> m a Source

equivalentBy :: (a -> a -> Bool) -> [a] -> Bool Source

A generalisation of equivalent to any equivalence relation. equivalent = equivalentBy (==)

equivalent :: Eq a => [a] -> Bool Source

Determine if all elements of a list are equal.

whenJust :: Monad m => (a -> m ()) -> Maybe a -> m () Source

Perform the monadic action only in the Just case.

maybeM :: Monad m => String -> Maybe a -> m a Source

Lift a Maybe into an arbitrary monad, using return or fail.