Skip to content

Commit

Permalink
Fixed bug: Units aren't printed
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieBosio committed May 14, 2024
1 parent 43fe2f6 commit d59ee89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions benchmark/XYZW.con
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-- * X, Y, Z, W
adt X = Stop | XY Y | XZ Z | XW W .

adt Y = YY Unit X .
adt Z = ZZ Boolean X .
adt W = WW Integer X .
adt Y = YY Boolean Boolean X .
adt Z = ZZ Boolean X .
adt W = WW Integer X .

falsifiableX :: X -> Boolean .
falsifiableX x =*=
case x of
; XY {YY {Unit, XZ {ZZ {True, XW {WW {5, Stop}}}}}} -> False
; XY {YY {True, False, XZ {ZZ {True, XW {WW {5, Stop}}}}}} -> False
; y -> True .
8 changes: 4 additions & 4 deletions benchmark/XYZW.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module XYZW where
import Test.Tasty.QuickCheck

data X = Stop | XY Y | XZ Z | XW W deriving (Show, Eq)
data Y = YY () X deriving (Show, Eq)
data Z = ZZ Bool X deriving (Show, Eq)
data W = WW Integer X deriving (Show, Eq)
data Y = YY Bool Bool X deriving (Show, Eq)
data Z = ZZ Bool X deriving (Show, Eq)
data W = WW Integer X deriving (Show, Eq)

instance Arbitrary X where
arbitrary = sized genX
Expand All @@ -23,7 +23,7 @@ instance Arbitrary Y where
arbitrary = genY 0

genY :: Int -> Gen Y
genY _ = YY () <$> arbitrary
genY _ = YY <$> arbitrary <*> arbitrary <*> arbitrary

instance Arbitrary Z where
arbitrary = genZ 0
Expand Down
12 changes: 6 additions & 6 deletions test/Benchmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ bToContra (Two v) = VConstructor "Two" [aToContra v] (ADT "B")

-- * X Y Z W
data X = Stop | XY Y | XZ Z | XW W deriving (Show, Eq)
data Y = YY () X deriving (Show, Eq)
data Z = ZZ Bool X deriving (Show, Eq)
data W = WW Integer X deriving (Show, Eq)
data Y = YY Bool Bool X deriving (Show, Eq)
data Z = ZZ Bool X deriving (Show, Eq)
data W = WW Integer X deriving (Show, Eq)

instance QC.Arbitrary X where
arbitrary = QC.sized genX
Expand All @@ -171,7 +171,7 @@ instance QC.Arbitrary Y where
arbitrary = genY 0

genY :: Int -> QC.Gen Y
genY _ = YY () <$> QC.arbitrary
genY _ = YY <$> QC.arbitrary <*> QC.arbitrary <*> QC.arbitrary

instance QC.Arbitrary Z where
arbitrary = genZ 0
Expand All @@ -198,7 +198,7 @@ x adt = QC.ioProperty $
contraX :: Value Type -> Program Type
contraX v =
Data "X" [Constructor "Stop" [],Constructor "XY" [ADT "Y"],Constructor "XZ" [ADT "Z"],Constructor "XW" [ADT "W"]]
(Data "Y" [Constructor "YY" [Unit',ADT "X"]]
(Data "Y" [Constructor "YY" [Boolean',Boolean',ADT "X"]]
(Data "Z" [Constructor "ZZ" [Boolean',ADT "X"]]
(Data "W" [Constructor "WW" [Integer',ADT "X"]]
(Signature "quickCheck" (ADT "X" :->: Boolean')
Expand All @@ -218,7 +218,7 @@ xToContra (XZ z) = VConstructor "XZ" [zToContra z] (ADT "X")
xToContra (XW w) = VConstructor "XW" [wToContra w] (ADT "X")

yToContra :: Y -> Value Type
yToContra (YY () x') = VConstructor "YY" [Unit Unit', xToContra x'] (ADT "Y")
yToContra (YY bool1 bool2 x') = VConstructor "YY" [Boolean bool1 Boolean', Boolean bool2 Boolean', xToContra x'] (ADT "Y")

zToContra :: Z -> Value Type
zToContra (ZZ bool x') = VConstructor "ZZ" [Boolean bool Boolean', xToContra x'] (ADT "Z")
Expand Down

0 comments on commit d59ee89

Please sign in to comment.