Skip to content

Commit 7bfef2e

Browse files
authored
Convert hedgehog api to use new hedgehog effect (#13)
* Hide -Werror in dev flag * Convert hedgehog api to use new hedgehog effect that supports property tests * Remove unused type class MonadTestProxy * Convert hedgehog api to use new effects * Move PropertyTest and UnitTest types to their own modules * Disable deprecations in Effectful.Zoo.Core.Prim * Bump tasty version * Re-exports from Effectful.Zoo.Hedgehog.Data * Refactor Core submodules to not be submodules
1 parent 91333c3 commit 7bfef2e

File tree

30 files changed

+304
-555
lines changed

30 files changed

+304
-555
lines changed

components/blockfrost/Effectful/Zoo/Blockfrost/Api.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ import Data.Maybe
339339
import Data.Text
340340
import Effectful
341341
import Effectful.Dispatch.Dynamic
342-
import Effectful.Zoo.Core.Error.Static
343342
import Effectful.Zoo.Blockfrost.Dynamic (Blockfrost, runBlockfrost)
344343
import Effectful.Zoo.Blockfrost.Dynamic qualified as BF
345344
import Effectful.Zoo.Core
345+
import Effectful.Zoo.Error.Static
346346
import HaskellWorks.Prelude
347347

348348
-- Client

components/core/Effectful/Zoo/Aeson.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Data.Aeson qualified as Aeson
77
import Data.ByteString.Lazy qualified as LBS
88
import Effectful
99
import Effectful.Zoo.Core
10-
import Effectful.Zoo.Core.Error.Static
10+
import Effectful.Zoo.Error.Static
1111
import HaskellWorks.Error.Types.JsonDecodeError
1212
import HaskellWorks.Prelude
1313

components/core/Effectful/Zoo/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ module Effectful.Zoo.Core
33
type (<<:),
44
) where
55

6-
import Effectful.Zoo.Core.Prim
6+
import Effectful.Zoo.Prim

components/core/Effectful/Zoo/Core/Error/Dynamic.hs renamed to components/core/Effectful/Zoo/Error/Dynamic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Effectful.Zoo.Core.Error.Dynamic
1+
module Effectful.Zoo.Error.Dynamic
22
( Error,
33

44
throw,

components/core/Effectful/Zoo/Core/Error/Static.hs renamed to components/core/Effectful/Zoo/Error/Static.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Effectful.Zoo.Core.Error.Static
1+
module Effectful.Zoo.Error.Static
22
( Error,
33

44
throw,
@@ -33,7 +33,7 @@ module Effectful.Zoo.Core.Error.Static
3333
import Effectful
3434
import Effectful.Error.Static (Error, runError)
3535
import Effectful.Error.Static qualified as E
36-
import Effectful.Zoo.Core
36+
import Effectful.Zoo.Prim
3737
import HaskellWorks.Prelude
3838

3939
throw :: forall e r a. ()

components/core/Effectful/Zoo/Core/Exception.hs renamed to components/core/Effectful/Zoo/Exception.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Effectful.Zoo.Core.Exception
1+
module Effectful.Zoo.Exception
22
( Exception,
33
catchIO,
44
throwIO,

components/core/Effectful/Zoo/FileSystem.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import Effectful
2525
import Effectful.Dispatch.Static
2626
import Effectful.FileSystem (FileSystem)
2727
import Effectful.Zoo.Core
28-
import Effectful.Zoo.Core.Error.Static
29-
import Effectful.Zoo.Core.Exception
28+
import Effectful.Zoo.Error.Static
29+
import Effectful.Zoo.Exception
3030
import Effectful.Zoo.Log.Api.Text
3131
import Effectful.Zoo.Log.Dynamic
3232
import Effectful.Zoo.Unsafe

components/core/Effectful/Zoo/Core/Function.hs renamed to components/core/Effectful/Zoo/Function.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module Effectful.Zoo.Core.Function
1+
module Effectful.Zoo.Function
22
( once,
33
) where
44

55
import Effectful
66
import Effectful.Concurrent
77
import Effectful.Concurrent.MVar
8-
import Effectful.Zoo.Core.Prim
8+
import Effectful.Zoo.Prim
99
import HaskellWorks.Prelude
1010

1111
once :: ()

components/core/Effectful/Zoo/Core/Prim.hs renamed to components/core/Effectful/Zoo/Prim.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module Effectful.Zoo.Core.Prim
1+
{-# OPTIONS_GHC -fno-warn-deprecations #-}
2+
3+
module Effectful.Zoo.Prim
24
( type (<:),
35
type (<<:)
46
) where

components/hedgehog-test/Effectful/Zoo/Hedgehog/Test/HedgehogTest.hs

Lines changed: 0 additions & 32 deletions
This file was deleted.

components/hedgehog-test/Main.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
module Main where
22

33
import Effectful.Zoo.Hedgehog.Api.Tasty
4-
import Effectful.Zoo.Hedgehog.Test.HedgehogTest (test_simple)
54
import Effectful.Zoo.Hedgehog.Test.PropertySpec
65
import Test.Tasty (TestTree, defaultMain, testGroup)
76
import HaskellWorks.Prelude
87

98
tests :: TestTree
109
tests =
1110
testGroup "all"
12-
[ toTestTree "Simple test" test_simple
13-
, toTestTree "Simple property spec" property_spec
11+
[ toTestTree "Simple property spec" property_spec
1412
, toTestTree "Simple test spec" test_spec
1513
]
1614

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
module Effectful.Zoo.Hedgehog.Api
22
( module Effectful.Zoo.Hedgehog.Api.Assert,
3-
module Effectful.Zoo.Hedgehog.Api.Classify,
4-
module Effectful.Zoo.Hedgehog.Api.Eval,
3+
module Effectful.Zoo.Hedgehog.Api.Hedgehog,
54
module Effectful.Zoo.Hedgehog.Api.Failure,
65
module Effectful.Zoo.Hedgehog.Api.Journal,
7-
module Effectful.Zoo.Hedgehog.Api.Run,
86
) where
97

108
import Effectful.Zoo.Hedgehog.Api.Assert
11-
import Effectful.Zoo.Hedgehog.Api.Classify
12-
import Effectful.Zoo.Hedgehog.Api.Eval
139
import Effectful.Zoo.Hedgehog.Api.Failure
10+
import Effectful.Zoo.Hedgehog.Api.Hedgehog
1411
import Effectful.Zoo.Hedgehog.Api.Journal
15-
import Effectful.Zoo.Hedgehog.Api.Run

components/hedgehog/Effectful/Zoo/Hedgehog/Api/Assert.hs

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
module Effectful.Zoo.Hedgehog.Api.Assert
2-
( assert,
3-
(===),
4-
(/==),
5-
onNothingFail,
2+
( onNothingFail,
63
onNothingFailM,
74
onLeftFail,
85
onLeftFailM,
@@ -22,93 +19,62 @@ import Data.Text.Lazy qualified as LT
2219
import Data.Text.Lazy.Encoding qualified as LT
2320
import Data.Yaml qualified as Y
2421
import Effectful
22+
import Effectful.Concurrent
2523
import Effectful.Dispatch.Dynamic
2624
import Effectful.Zoo.Core
27-
import Effectful.Zoo.Core.Error.Static
28-
import Effectful.Zoo.Hedgehog.Api.Failure
29-
import Effectful.Zoo.Hedgehog.Dynamic
25+
import Effectful.Zoo.Error.Static
26+
import Effectful.Zoo.Hedgehog.Api.Hedgehog
27+
import Effectful.Zoo.Hedgehog.Effect.Hedgehog
3028
import HaskellWorks.Prelude
31-
import Hedgehog qualified as H
29+
import Hedgehog (MonadTest(..))
30+
import Hedgehog.Internal.Property qualified as H
3231

33-
infix 4 ===, /==
34-
35-
assert :: forall r. ()
36-
=> HasCallStack
37-
=> r <: Hedgehog
38-
=> Bool
39-
-> Eff r ()
40-
assert condition =
41-
withFrozenCallStack $
42-
H.assert condition
43-
44-
(===) :: forall a r. ()
32+
onNothingFail :: forall a m. ()
4533
=> HasCallStack
46-
=> Eq a
47-
=> Show a
48-
=> r <: Hedgehog
49-
=> a
50-
-> a
51-
-> Eff r ()
52-
(===) a b =
53-
withFrozenCallStack $
54-
a H.=== b
55-
56-
(/==) :: forall a r. ()
57-
=> HasCallStack
58-
=> Eq a
59-
=> Show a
60-
=> r <: Hedgehog
61-
=> a
62-
-> a
63-
-> Eff r ()
64-
(/==) a b =
65-
withFrozenCallStack $
66-
a H./== b
67-
68-
onNothingFail :: forall a r. ()
69-
=> HasCallStack
70-
=> r <: Hedgehog
34+
=> MonadTest m
7135
=> Maybe a
72-
-> Eff r a
36+
-> m a
7337
onNothingFail mv =
7438
withFrozenCallStack $
7539
case mv of
7640
Just a -> pure a
7741
Nothing -> failWith Nothing "Expected Just, but got Nothing"
7842

79-
onNothingFailM :: forall a r. ()
43+
onNothingFailM :: forall a m. ()
8044
=> HasCallStack
81-
=> r <: Hedgehog
82-
=> Eff r (Maybe a)
83-
-> Eff r a
45+
=> MonadTest m
46+
=> m (Maybe a)
47+
-> m a
8448
onNothingFailM f =
8549
withFrozenCallStack $
8650
f >>= onNothingFail
8751

88-
onLeftFail :: forall e a r. ()
52+
onLeftFail :: forall e a m. ()
8953
=> HasCallStack
54+
=> MonadTest m
9055
=> Show e
91-
=> r <: Hedgehog
9256
=> Either e a
93-
-> Eff r a
57+
-> m a
9458
onLeftFail ea =
9559
withFrozenCallStack $
9660
case ea of
9761
Right a -> pure a
9862
Left e -> failWith Nothing $ "Expected Just, but got Left: " <> show e
9963

100-
onLeftFailM :: forall e a r. ()
64+
onLeftFailM :: forall e a m. ()
10165
=> HasCallStack
66+
=> MonadTest m
10267
=> Show e
103-
=> r <: Hedgehog
104-
=> Eff r (Either e a)
105-
-> Eff r a
68+
=> m (Either e a)
69+
-> m a
10670
onLeftFailM f =
10771
withFrozenCallStack $
10872
f >>= onLeftFail
10973

11074
trapFail :: forall e a r. ()
11175
=> HasCallStack
76+
=> r <: Concurrent
77+
=> r <: Error H.Failure
11278
=> r <: Hedgehog
11379
=> Show e
11480
=> Eff (Error e ': r) a
@@ -122,6 +88,8 @@ trapFail f =
12288

12389
trapFailJson :: forall e a r. ()
12490
=> HasCallStack
91+
=> r <: Concurrent
92+
=> r <: Error H.Failure
12593
=> r <: Hedgehog
12694
=> ToJSON e
12795
=> Eff (Error e ': r) a
@@ -137,6 +105,8 @@ trapFailJson f =
137105

138106
trapFailJsonPretty :: forall e a r. ()
139107
=> HasCallStack
108+
=> r <: Concurrent
109+
=> r <: Error H.Failure
140110
=> r <: Hedgehog
141111
=> ToJSON e
142112
=> Eff (Error e ': r) a
@@ -152,6 +122,8 @@ trapFailJsonPretty f =
152122

153123
trapFailYaml :: forall e a r. ()
154124
=> HasCallStack
125+
=> r <: Concurrent
126+
=> r <: Error H.Failure
155127
=> r <: Hedgehog
156128
=> ToJSON e
157129
=> Eff (Error e ': r) a

components/hedgehog/Effectful/Zoo/Hedgehog/Api/Classify.hs

Lines changed: 0 additions & 20 deletions
This file was deleted.

components/hedgehog/Effectful/Zoo/Hedgehog/Api/Eval.hs

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)