Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed Apr 25, 2024
1 parent 6e8b5f2 commit 909498a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 0 additions & 21 deletions libs/constrained-generators/src/Constrained/Examples/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Constrained.Examples.Basic where
import GHC.Generics

import Constrained
import Constrained.Base

leqPair :: Specification BaseFn (Int, Int)
leqPair = constrained $ \p ->
Expand Down Expand Up @@ -151,23 +150,3 @@ basicSpec = constrained $ \x ->
unsafeExists $ \y ->
satisfies x $ constrained $ \x' ->
x' <=. 1 + y

newtype Listy a = Listy [a] deriving (Ord, Eq, Show, Generic)
instance HasSimpleRep (Listy a)
instance HasSpec fn a => HasSpec fn (Listy a)

matchMatch :: Specification BaseFn (Listy Int, Listy Int)
matchMatch = constrained' $ \wxs wys ->
match wxs $ \xs ->
match wys $ \ys ->
[ satisfies xs $ liftSizeSpec (rangeSize 1 2)
, satisfies ys $ liftSizeSpec (rangeSize 1 2)
]

matchMatch' :: Specification BaseFn (Listy Int, Listy Int)
matchMatch' = constrained' $ \wxs wys ->
match wxs $ \xs ->
[ satisfies xs $ liftSizeSpec (rangeSize 1 2)
, match wys $ \ys ->
satisfies ys $ liftSizeSpec (rangeSize 1 2)
]
21 changes: 21 additions & 0 deletions libs/constrained-generators/src/Constrained/Examples/Map.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Data.Word
import GHC.Generics

import Constrained
import Constrained.Base

mapElemSpec :: Specification BaseFn (Map Int (Bool, Int))
mapElemSpec = constrained $ \m ->
Expand Down Expand Up @@ -57,3 +58,23 @@ fixedRange = constrained $ \m ->
[ forAll (rng_ m) (\x -> x ==. 5)
, assert $ (sizeOf_ m) ==. 1
]

newtype Mappy a = Mappy (Map Int a) deriving (Ord, Eq, Show, Generic)
instance HasSimpleRep (Mappy a)
instance HasSpec fn a => HasSpec fn (Mappy a)

matchMatch :: Specification BaseFn (Mappy Int, Mappy Int)
matchMatch = constrained' $ \wxs wys ->
match wxs $ \xs ->
match wys $ \ys ->
[ satisfies xs $ liftSizeSpec (rangeSize 1 2)
, satisfies ys $ liftSizeSpec (rangeSize 1 2)
]

matchMatch' :: Specification BaseFn (Mappy Int, Mappy Int)
matchMatch' = constrained' $ \wxs wys ->
match wxs $ \xs ->
[ satisfies xs $ liftSizeSpec (rangeSize 1 2)
, match wys $ \ys ->
satisfies ys $ liftSizeSpec (rangeSize 1 2)
]

0 comments on commit 909498a

Please sign in to comment.