1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 21:31:48 +03:00

Reformat a bunch of signatures.

This commit is contained in:
Rob Rix 2018-03-14 10:33:39 -04:00
parent 568cda0f12
commit 86626ca242

View File

@ -71,7 +71,11 @@ class (MonadAnalysis term value m, Show value) => MonadValue term value m where
toBool :: MonadValue term value m => value -> m Bool
toBool v = ifthenelse v (pure True) (pure False)
forLoop :: (MonadAddressable (LocationFor value) value m, MonadEnvironment value m, MonadStore value m, MonadValue term value m)
forLoop :: ( MonadAddressable (LocationFor value) value m
, MonadEnvironment value m
, MonadStore value m
, MonadValue term value m
)
=> m value -- | Initial statement
-> m value -- | Condition
-> m value -- | Increment/stepper
@ -83,21 +87,45 @@ forLoop initial cond step body = do
localEnv (mappend env) (while cond (body *> step))
-- | The fundamental looping primitive, built on top of ifthenelse.
while :: (MonadAddressable (LocationFor value) value m, MonadEnvironment value m, MonadStore value m, MonadValue term value m) => m value -> m value -> m value
while :: ( MonadAddressable (LocationFor value) value m
, MonadEnvironment value m
, MonadStore value m
, MonadValue term value m
)
=> m value
-> m value
-> m value
while cond body = loop $ do
this <- cond
ifthenelse this (body *> continue) unit
-- | Do-while loop, built on top of while.
doWhile :: (MonadAddressable (LocationFor value) value m, MonadEnvironment value m, MonadStore value m, MonadValue term value m) => m value -> m value -> m value
doWhile :: ( MonadAddressable (LocationFor value) value m
, MonadEnvironment value m
, MonadStore value m
, MonadValue term value m
)
=> m value
-> m value
-> m value
doWhile body cond = loop $ body *> do
this <- cond
ifthenelse this continue unit
loop :: (MonadAddressable (LocationFor value) value m, MonadEnvironment value m, MonadStore value m) => m value -> m value
loop :: ( MonadAddressable (LocationFor value) value m
, MonadEnvironment value m
, MonadStore value m
)
=> m value
-> m value
loop = letrec (name "loop")
continue :: (MonadAddressable (LocationFor value) value m, MonadEnvironment value m, MonadStore value m, MonadValue term value m) => m value
continue :: ( MonadAddressable (LocationFor value) value m
, MonadEnvironment value m
, MonadFail m
, MonadStore value m
)
=> m value
continue = do
env <- askLocalEnv
maybe (fail "free loop variable") deref (envLookup (name "loop") env)