Copyright | (c) John Maraist 2022 |
---|---|
License | AllRightsReserved |
Maintainer | haskell-tms@maraist.org |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, for NON-COMMERCIAL use. See the License for the specific language governing permissions and limitations under the License.
Synopsis
- anyByM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- anyMM :: Monad m => (a -> m Bool) -> m [a] -> m Bool
- allByM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- ordSubsetp :: Ord a => [a] -> [a] -> Bool
- formatList :: Monad m => String -> (a -> m String) -> [a] -> m String
- forMM_ :: (Monad m, Foldable t) => m (t a) -> (a -> m ()) -> m ()
- whileDo :: Monad m => m Bool -> m () -> m ()
- whileDoWith :: Monad m => m a -> (a -> Bool) -> (a -> m ()) -> m ()
- forMwhile_ :: Monad m => [a] -> m Bool -> (a -> m ()) -> m ()
- forMMwhile_ :: Monad m => m [a] -> m Bool -> (a -> m ()) -> m ()
- whileReturnJust :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()
- unlessMM :: Monad m => m Bool -> m () -> m ()
- nullR :: Monad m => STRef s [a] -> STT s m Bool
- nonnullR :: Monad m => STRef s [a] -> STT s m Bool
- whenNonnullR :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> STRef s [a] -> ([a] -> m ()) -> m ()
- mapRefs :: Monad m => (a -> b) -> [STRef s a] -> STT s m [b]
- foldrRefs :: Monad m => (a -> b -> b) -> b -> [STRef s a] -> STT s m b
- foldlRefs :: Monad m => (b -> a -> b) -> b -> [STRef s a] -> STT s m b
- forRM_ :: (Monad m, Monad m0, Foldable t) => (STT s m0 (t a) -> m (t a)) -> STRef s (t a) -> (a -> m ()) -> m ()
- push :: Monad m => a -> STRef s [a] -> STT s m ()
- pushM :: Monad m => m a -> STRef s [a] -> STT s m ()
- pushAll :: (Monad m, Traversable t) => t a -> STRef s [a] -> STT s m ()
- pushAllM :: (Monad m, Traversable t) => m (t a) -> STRef s [a] -> STT s m ()
- pop :: Monad m => STRef s [a] -> STT s m (Maybe a)
- whileListM_ :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> STRef s [a] -> (a -> m ()) -> m ()
- commaList :: (a -> String) -> [a] -> String
- unmaybe :: [Maybe a] -> [a]
Lists and monads
anyByM :: Monad m => (a -> m Bool) -> [a] -> m Bool Source #
Check whether a list contains a value which, when applied to a
computation, returns True
.
anyMM :: Monad m => (a -> m Bool) -> m [a] -> m Bool Source #
Check whether a returned list contains a value which satisfies some monadic predicate.
allByM :: Monad m => (a -> m Bool) -> [a] -> m Bool Source #
Check whether all of the values of a list, when applied to a
computation, return True
.
Ordered lists
ordSubsetp :: Ord a => [a] -> [a] -> Bool Source #
Determine whether one list is a subset of the other, under the assumption that both lists are sorted in ascending order.
Even more loops
formatList :: Monad m => String -> (a -> m String) -> [a] -> m String Source #
Convert a list to a string, where the converter for each element is a monadic computation.
forMM_ :: (Monad m, Foldable t) => m (t a) -> (a -> m ()) -> m () Source #
Like forM_
, but with both the elements source as well as the
loop body as computations over the monad.
whileDoWith :: Monad m => m a -> (a -> Bool) -> (a -> m ()) -> m () Source #
A while
loop based on stuff, guard at the top.
forMwhile_ :: Monad m => [a] -> m Bool -> (a -> m ()) -> m () Source #
Like forM_
, but with an extra check run after the body of the
loop. If the check fails, the loop exits early.
forMMwhile_ :: Monad m => m [a] -> m Bool -> (a -> m ()) -> m () Source #
Like forMwhile_
, but the source list is also the result of a
monadic computation.
whileReturnJust :: Monad m => m (Maybe a) -> (a -> m ()) -> m () Source #
unlessMM :: Monad m => m Bool -> m () -> m () Source #
Like unless
, expect both the tested value and the body are
returned from a computation in a monad.
Lists under references in the STT
monad transformer
whenNonnullR :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> STRef s [a] -> ([a] -> m ()) -> m () Source #
mapRefs :: Monad m => (a -> b) -> [STRef s a] -> STT s m [b] Source #
Map over the values contained within a list of references.
foldrRefs :: Monad m => (a -> b -> b) -> b -> [STRef s a] -> STT s m b Source #
Fold (right-associatively) the values contained within a list of references.
foldlRefs :: Monad m => (b -> a -> b) -> b -> [STRef s a] -> STT s m b Source #
Fold (left-associatively) the values contained within a list of references.
forRM_ :: (Monad m, Monad m0, Foldable t) => (STT s m0 (t a) -> m (t a)) -> STRef s (t a) -> (a -> m ()) -> m () Source #
Stack-like operations
push :: Monad m => a -> STRef s [a] -> STT s m () Source #
Push a value onto the front of the list at the given STT
reference.
pushM :: Monad m => m a -> STRef s [a] -> STT s m () Source #
Push the result of a computation onto the front of the list at the
given STT
reference.
pushAll :: (Monad m, Traversable t) => t a -> STRef s [a] -> STT s m () Source #
Push every value in a collection onto the front of the list at the
given STT
reference.
pushAllM :: (Monad m, Traversable t) => m (t a) -> STRef s [a] -> STT s m () Source #
Push every value in a collection returned from a computation onto
the front of the list at the given STT
reference.
pop :: Monad m => STRef s [a] -> STT s m (Maybe a) Source #
Pop a value from the given reference to a list if one exists.
whileListM_ :: (Monad m0, Monad m) => (forall r. STT s m0 r -> m r) -> STRef s [a] -> (a -> m ()) -> m () Source #
Consumes the elements of a referenced list, one at a time, until
the list is empty. The first argument is a lift
-style function
which brings STT
operations into the top-level monad of interest.
Intended to be compatible with stack-like behavior (such as with
push
; this function does use pop
) where the body of the loop
may add elements.