Popularity
1.1
Declining
Activity
0.0
Stable
1
1
0

Monthly Downloads: 15
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Unclassified    

almost-fix alternatives and similar packages

Based on the "Unclassified" category.
Alternatively, view almost-fix alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of almost-fix or a related project?

Add another 'Unclassified' Package

README

almost-fix

Combinators for predicative recursion

Usage

Simple Predicative Recursion

Say you want to perform f until some boolean test b:

almostFix b f

will run f until b returns False.

almostFix True f  ~  f . f . f ...

Monadic Predicates

Say you've got a monadic step f :: a -> m a, and some boolean test in the monad b :: m Bool - a good example of this would be in a MonadState Integer m stateful monad, and the monadic predicate liftM (< 5) get :: m Bool. Now, we bind until the predicate is falsified:

exclaimAgain :: MonadState Integer m => String -> m String
exclaimAgain a = do modify (+1)
                    return (a ++ "!")

exclaimFive :: String -> String
exclaimFive s = evalState (almostFix (liftM (<= 5) get) exclaimAgain s) 1