Skip to content

A monad transformer for handling backtrack in continuation based programs

Notifications You must be signed in to change notification settings

kavya-shree-s/purescript-backtrack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-backtrack

A monad transformer for implementing backtracking in continuation based program.

This library is purescript equivalent of Haskell library failback-monad

Installation

bower install purescript-backtrack

Example

main :: forall e. Eff (console::CONSOLE,random:: RANDOM|e) (FailBack Unit)
main = runBackT $ do
  _ ← BackT $ pure <$> log "Starting Run"
  a ← backpointRandomInt
  _ ← BackT $ pure <$> log "Generated a number"
  _ ← if (a >= 9) then pure unit else BackT (pure GoBack)
  b ← backpointRandomInt
  _ ← BackT $ pure <$> log "Generated another number"
  _ ← if (b >= 9) then pure unit else BackT (pure GoBack)
  BackT $ pure <$> logShow (a + b)

backpointRandomInt :: forall eff. BackT (Eff ( random :: RANDOM | eff)) Int
backpointRandomInt = BackT $ BackPoint <$> (randomInt 1 10)

About

A monad transformer for handling backtrack in continuation based programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PureScript 100.0%