Skip to content

Commit bdd211b

Browse files
committed
stackify
1 parent 04d5f23 commit bdd211b

File tree

3 files changed

+86
-24
lines changed

3 files changed

+86
-24
lines changed

Language/Boogie/ErrorAccum.hs

+16-15
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
module Language.Boogie.ErrorAccum where
44

55
import Control.Monad
6+
import Control.Applicative
67
import Control.Monad.Trans
78
import Control.Monad.Trans.Error
89

9-
-- | Error accumulator:
10-
-- used in combination with ErrorT to store intermediate computation results,
11-
-- when errors should be accumulated rather than reported immediately
10+
-- | Error accumulator:
11+
-- used in combination with ErrorT to store intermediate computation results,
12+
-- when errors should be accumulated rather than reported immediately
1213
newtype ErrorAccumT e m a = ErrorAccumT { runErrorAccumT :: m ([e], a) }
1314

1415
instance (ErrorList e, Monad m) => Functor (ErrorAccumT e m) where
@@ -29,48 +30,48 @@ instance (ErrorList e, Monad m) => Monad (ErrorAccumT e m) where
2930
(errs', res') <- runErrorAccumT $ k res
3031
return (errs ++ errs', res')
3132

32-
33+
3334
instance ErrorList e => MonadTrans (ErrorAccumT e) where
3435
lift m = ErrorAccumT $ do
3536
a <- m
36-
return ([], a)
37-
37+
return ([], a)
38+
3839
-- | Transform an error computation and default value into an error accumlator
3940
accum :: (ErrorList e, Monad m) => ErrorT [e] m a -> a -> ErrorAccumT e m a
4041
accum c def = ErrorAccumT (errToAccum def `liftM` runErrorT c)
4142
where
4243
errToAccum def (Left errs) = (errs, def)
4344
errToAccum def (Right x) = ([], x)
44-
45-
-- | Transform an error accumlator back into a regular error computation
45+
46+
-- | Transform an error accumlator back into a regular error computation
4647
report :: (ErrorList e, Monad m) => ErrorAccumT e m a -> ErrorT [e] m a
4748
report accum = ErrorT (accumToErr `liftM` runErrorAccumT accum)
4849
where
4950
accumToErr ([], x) = Right x
50-
accumToErr (es, _) = Left es
51+
accumToErr (es, _) = Left es
5152

5253
-- | 'mapAccum' @f def xs@ :
5354
-- Apply @f@ to all @xs@, accumulating errors and reporting them at the end
5455
mapAccum :: (ErrorList e, Monad m) => (a -> ErrorT [e] m b) -> b -> [a] -> ErrorT [e] m [b]
55-
mapAccum f def xs = report $ mapM (acc f) xs
56+
mapAccum f def xs = report $ mapM (acc f) xs
5657
where
5758
acc f x = accum (f x) def
58-
59+
5960
-- | 'mapAccumA_' @f xs@ :
6061
-- Apply @f@ to all @xs@ throwing away the result, accumulating errors
6162
mapAccumA_ :: (ErrorList e, Monad m) => (a -> ErrorT [e] m ()) -> [a] -> ErrorAccumT e m ()
62-
mapAccumA_ f xs = mapM_ (acc f) xs
63+
mapAccumA_ f xs = mapM_ (acc f) xs
6364
where
6465
acc f x = accum (f x) ()
65-
66+
6667
-- | Same as 'mapAccumA_', but reporting errors at the end
6768
mapAccum_ :: (ErrorList e, Monad m) => (a -> ErrorT [e] m ()) -> [a] -> ErrorT [e] m ()
68-
mapAccum_ f xs = report $ mapAccumA_ f xs
69+
mapAccum_ f xs = report $ mapAccumA_ f xs
6970

7071
-- | 'zipWithAccum_' @f xs ys@ :
7172
-- Apply type checking @f@ to all @xs@ and @ys@ throwing away the result,
7273
-- accumulating errors and reporting them at the end
7374
zipWithAccum_ :: (ErrorList e, Monad m) => (a -> b -> ErrorT [e] m ()) -> [a] -> [b] -> ErrorT [e] m ()
74-
zipWithAccum_ f xs ys = report $ zipWithM_ (acc f) xs ys
75+
zipWithAccum_ f xs ys = report $ zipWithM_ (acc f) xs ys
7576
where
7677
acc f x y = accum (f x y) ()

language-boogie.cabal

+35-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license-file: LICENSE
99
author: Nadia Polikarpova
1010
maintainer: nadia.polikarpova@gmail.com
1111
category: Language
12-
tested-with: GHC==7.4.1, GHC==7.6.2
12+
tested-with: GHC==7.4.1, GHC==7.6.2, GHC==7.8.4
1313
build-type: Simple
1414
cabal-version: >=1.8
1515

@@ -19,7 +19,7 @@ source-repository head
1919

2020
flag boogaloo
2121
Description: Build the boogaloo executable
22-
Default: True
22+
Default: False
2323

2424
flag tests
2525
Description: Build boogaloo-tests executable
@@ -63,8 +63,8 @@ library
6363
lens >=4.13,
6464
logict,
6565
z3 >=0.3
66-
67-
66+
67+
6868
executable boogaloo
6969
main-is: Boogaloo.hs
7070
ghc-options: -threaded
@@ -88,8 +88,34 @@ executable boogaloo
8888
time ==1.4.*,
8989
ansi-terminal >=0.5
9090
If !flag(boogaloo)
91-
buildable: False
92-
91+
buildable: False
92+
93+
test-suite boogaloo-test
94+
type: exitcode-stdio-1.0
95+
hs-source-dirs: .
96+
main-is: Tests.hs
97+
build-depends:
98+
base ==4.*,
99+
random ==1.0.*,
100+
containers >=0.4 && <0.6,
101+
mtl ==2.1.*,
102+
ansi-wl-pprint >=0.6,
103+
html ==1.*,
104+
parsec ==3.1.*,
105+
transformers ==0.3.*,
106+
stream-monad ==0.4.*,
107+
random ==1.0.*,
108+
syb >=0.1,
109+
lens >=4.13,
110+
z3 >=0.3,
111+
language-boogie ==0.2.*,
112+
filepath ==1.3.*,
113+
html ==1.*,
114+
HUnit ==1.2.*,
115+
logict
116+
If !flag(tests)
117+
buildable: False
118+
93119
executable boogaloo-tests
94120
main-is: Tests.hs
95121
build-depends:
@@ -109,7 +135,7 @@ executable boogaloo-tests
109135
language-boogie ==0.2.*,
110136
filepath ==1.3.*,
111137
html ==1.*,
112-
HUnit ==1.2.*
138+
HUnit ==1.2.*,
139+
logict
113140
If !flag(tests)
114-
buildable: False
115-
141+
buildable: False

stack.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
flags:
3+
generic-deriving:
4+
base-4-9: false
5+
language-boogie:
6+
boogaloo: true
7+
tests: true
8+
extra-package-dbs: []
9+
packages:
10+
- .
11+
extra-deps:
12+
- lens-4.13
13+
- z3-4.2.0
14+
- random-1.0.0.0
15+
- mtl-2.1.2
16+
- ansi-wl-pprint-0.6.4
17+
- html-1.0
18+
- parsec-3.1.0
19+
- ansi-terminal-0.5.0
20+
- stream-monad-0.4.0.2
21+
- base-orphans-0.4.0
22+
- tagged-0.7.3
23+
- adjunctions-4.2.1
24+
- free-4.12
25+
- bifunctors-5
26+
- profunctors-5
27+
- semigroupoids-5
28+
- comonad-4.2.7.1
29+
- kan-extensions-4.2.2
30+
- reflection-2.1
31+
- nats-0.1
32+
- logict-0.5.0.2
33+
- text-0.11.3.1
34+
35+
resolver: lts-2.0

0 commit comments

Comments
 (0)