Skip to content

Commit

Permalink
'reset' for delimited continuations
Browse files Browse the repository at this point in the history
  • Loading branch information
krangelov committed Mar 15, 2024
1 parent 1fd0e9d commit 614f4b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/compiler/api/GF/Compile/Compute/Concrete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module GF.Compile.Compute.Concrete
( normalForm, normalStringForm
, Value(..), Thunk, ThunkState(..), Env, Scope, showValue
, MetaThunks, Constraint, Globals(..), ConstValue(..)
, EvalM(..), runEvalM, runEvalOneM, evalError, evalWarn
, EvalM(..), runEvalM, runEvalOneM, reset, evalError, evalWarn
, eval, apply, force, value2term, patternMatch, stdPredef
, unsafeIOToEvalM
, newThunk, newEvaluatedThunk
Expand Down Expand Up @@ -755,6 +755,13 @@ runEvalOneM gr f = Check $ \(es,ws) ->
Success [] ws -> Fail (pp "The evaluation produced no results") (es,ws)
Success (x:_) ws -> Success x (es,ws)

reset :: EvalM s a -> EvalM s [a]
reset (EvalM f) = EvalM $ \gl k mt d r ws -> do
res <- f gl (\x mt d xs ws -> return (Success (x:xs) ws)) mt d [] ws
case res of
Fail msg ws -> return (Fail msg ws)
Success xs ws -> k (reverse xs) mt d r ws

evalError :: Message -> EvalM s a
evalError msg = EvalM (\gr k _ _ r msgs -> return (Fail msg msgs))

Expand Down

0 comments on commit 614f4b2

Please sign in to comment.