Skip to content

Commit c1bea2d

Browse files
MorrowMisovector
andauthored
Fix #1879 (#2644)
Co-authored-by: Sandy Maguire <[email protected]>
1 parent ce41b64 commit c1bea2d

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

plugins/hls-tactics-plugin/src/Wingman/KnownStrategies/QuickCheck.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ deriveArbitrary = do
4343
mempty
4444
mempty
4545
mempty
46-
$ noLoc $
47-
let' [valBind (fromString "terminal") $ list $ fmap genExpr terminal] $
46+
$ noLoc $ case terminal of
47+
[onlyCon] -> genExpr onlyCon -- See #1879
48+
_ -> let' [valBind (fromString "terminal") $ list $ fmap genExpr terminal] $
4849
appDollar (mkFunc "sized") $ lambda [bvar' (mkVarOcc "n")] $
4950
case' (infixCall "<=" (mkVal "n") (int 1))
5051
[ match [conP (fromString "True") []] $

plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ spec = do
7272

7373
describe "known" $ do
7474
autoTest 25 13 "GoldenArbitrary"
75+
autoTest 6 13 "GoldenArbitrarySingleConstructor"
7576
autoTestNoWhitespace
7677
6 10 "KnownBigSemigroup"
7778
autoTest 4 10 "KnownThetaSemigroup"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
data Gen a
2+
3+
data Obj = Obj Int Bool Char String
4+
5+
arbitrary :: Gen Obj
6+
arbitrary
7+
= (((Obj <$> arbitrary) <*> arbitrary) <*> arbitrary) <*> arbitrary
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
data Gen a
2+
3+
data Obj = Obj Int Bool Char String
4+
5+
arbitrary :: Gen Obj
6+
arbitrary = _

0 commit comments

Comments
 (0)