From 86626ca2422d8fb51d3aa95ebf296cc0ee54ca3b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 14 Mar 2018 10:33:39 -0400 Subject: [PATCH] Reformat a bunch of signatures. --- src/Control/Abstract/Value.hs | 38 ++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index 7a082a87a..37d131dd7 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -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)