Safe Haskell | None |
---|---|
Language | Haskell2010 |
- failed :: MonadThrow m => String -> m a
- maybe2throw :: (a -> Maybe b) -> forall m. MonadThrow m => a -> m b
- list2throw :: (a -> [b]) -> forall m. MonadThrow m => a -> m b
- either2throw :: (a -> Either SomeException b) -> forall m. MonadThrow m => a -> m b
- throw2maybe :: (forall m. MonadThrow m => a -> m b) -> a -> Maybe b
- throw2either :: (forall m. MonadThrow m => a -> m b) -> a -> Either SomeException b
- throw2list :: (forall m. MonadThrow m => a -> m b) -> a -> [b]
- totalizeFunction :: (NFData b, MonadThrow m) => (a -> b) -> a -> m b
- defaultPartialityHandlers :: MonadThrow m => [Handler (m a)]
- spoonWith :: (NFData a, MonadThrow m) => [Handler (m a)] -> a -> m a
- showsPrecWith :: (Show a, Show b) => String -> (a -> b) -> Int -> a -> ShowS
- int2natural :: Int -> Natural
- powerSet :: Ord a => Set a -> Set (Set a)
- dropEach :: Ord a => Set a -> Set (Set a)
- powerset2matrix :: Set (Set a) -> [[a]]
Documentation
maybe2throw :: (a -> Maybe b) -> forall m. MonadThrow m => a -> m b Source
generalize a function that fails with Nothing
.
list2throw :: (a -> [b]) -> forall m. MonadThrow m => a -> m b Source
generalize a function that fails with []
.
either2throw :: (a -> Either SomeException b) -> forall m. MonadThrow m => a -> m b Source
generalize a function that fails with Left
.
throw2maybe :: (forall m. MonadThrow m => a -> m b) -> a -> Maybe b Source
specialization
throw2either :: (forall m. MonadThrow m => a -> m b) -> a -> Either SomeException b Source
specialization
throw2list :: (forall m. MonadThrow m => a -> m b) -> a -> [b] Source
specialization
totalizeFunction :: (NFData b, MonadThrow m) => (a -> b) -> a -> m b Source
makes an *unsafely*-partial function (i.e. a function that throws exceptions or that has inexhaustive pattern matching) into a *safely*-partial function (i.e. that explicitly returns in a monad that supports failure).
defaultPartialityHandlers :: MonadThrow m => [Handler (m a)] Source
handles the following exceptions:
spoonWith :: (NFData a, MonadThrow m) => [Handler (m a)] -> a -> m a Source
showsPrecWith :: (Show a, Show b) => String -> (a -> b) -> Int -> a -> ShowS Source
the eliminator as a function and the introducer as a string
helper for declaring Show instances of datatypes without visible constructors (like Map
which is shown as an list).
int2natural :: Int -> Natural Source
powerSet :: Ord a => Set a -> Set (Set a) Source
the power set of a set of values.
>>>
(powerset2matrix . powerSet . Set.fromList) [1..3]
[[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
dropEach :: Ord a => Set a -> Set (Set a) Source
>>>
(powerset2matrix . dropEach . Set.fromList) [1..3]
[[1,2],[1,3],[2,3]]
powerset2matrix :: Set (Set a) -> [[a]] Source
convert a power set to an isomorphic matrix, sorting the entries.
(for doctest)