File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 11module  Concur.Core.Patterns 
22( loopState 
3+ , loopState' 
34, retryUntil 
45, retryUntilLoop 
56, tea 
@@ -29,6 +30,7 @@ import Effect.Aff.Bus as ABus
2930import  Effect.Aff.Class  (class  MonadAff , liftAff )
3031import  Effect.Class  (class  MonadEffect , liftEffect )
3132
33+ 
3234--  | A very useful combinator for widgets with localised state
3335loopState  :: 
3436  forall  m  a  s .
@@ -40,6 +42,10 @@ loopState s f = f s >>= case _ of
4042  Left  s' ->  loopState s' f
4143  Right  a ->  pure a
4244
45+ --  | Never ending widgets with localised state
46+ loopState'  ::  forall  m  a  s . Monad  m  =>  (s  ->  m  s ) ->  s  ->  m  a 
47+ loopState' f s = f s >>= loopState' f
48+ 
4349--  | Repeat a computation until the value satisfies a predicate
4450retryUntil  ::  forall  m  a . Monad  m  =>  (a  ->  Boolean ) ->  m  a  ->  m  a 
4551retryUntil p w = w >>= \a ->  if  p a then  pure a else  retryUntil p w
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments