mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Extract a runFresh helper.
This commit is contained in:
parent
86ef19bbb0
commit
192367da0b
@ -19,9 +19,11 @@ fresh = raise (send Fresh)
|
||||
reset :: (Effectful m, Member Fresh effects) => Int -> m effects ()
|
||||
reset = raise . send . Reset
|
||||
|
||||
runFresh :: Eff (Fresh ': effects) a -> Eff effects a
|
||||
runFresh = relayState (0 :: Int) (const pure) (\ s action k -> case action of
|
||||
Fresh -> k (succ s) s
|
||||
Reset s' -> k s' ())
|
||||
|
||||
-- | 'Fresh' effects are interpreted starting from 0, incrementing the current name with each request for a fresh name, and overwriting the counter on reset.
|
||||
instance RunEffect Fresh a where
|
||||
runEffect = relayState (0 :: Int) (const pure) (\ s action k -> case action of
|
||||
Fresh -> k (succ s) s
|
||||
Reset s' -> k s' ())
|
||||
runEffect = runFresh
|
||||
|
Loading…
Reference in New Issue
Block a user