diff --git a/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/CodeGen/Utils.hs b/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/CodeGen/Utils.hs index 577e9ab94a..eb728066bc 100644 --- a/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/CodeGen/Utils.hs +++ b/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/CodeGen/Utils.hs @@ -21,7 +21,8 @@ mkCon dcon (fmap unLoc -> args) | dataConIsInfix dcon , (lhs : rhs : args') <- args = noLoc $ foldl' (@@) (op lhs (coerceName dcon_name) rhs) args' - | Just fields <- getRecordFields dcon = + | Just fields <- getRecordFields dcon + , length fields >= 2 = -- record notation is unnatural on single field ctors noLoc $ recordConE (coerceName dcon_name) $ do (arg, (field, _)) <- zip args fields pure (coerceName field, arg) diff --git a/plugins/hls-tactics-plugin/test/GoldenSpec.hs b/plugins/hls-tactics-plugin/test/GoldenSpec.hs index e7a263814f..80e4f26228 100644 --- a/plugins/hls-tactics-plugin/test/GoldenSpec.hs +++ b/plugins/hls-tactics-plugin/test/GoldenSpec.hs @@ -151,6 +151,7 @@ spec = do autoTest "GoldenArbitrary.hs" 25 13 autoTest "FmapBoth.hs" 2 12 autoTest "RecordCon.hs" 7 8 + autoTest "NewtypeRecord.hs" 6 8 autoTest "FmapJoin.hs" 2 14 autoTest "Fgmap.hs" 2 9 autoTest "FmapJoinInLet.hs" 4 19 diff --git a/plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs b/plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs new file mode 100644 index 0000000000..82b994b936 --- /dev/null +++ b/plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs @@ -0,0 +1,7 @@ +newtype MyRecord a = Record + { field1 :: a + } + +blah :: (a -> Int) -> a -> MyRecord a +blah = _ + diff --git a/plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs.expected b/plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs.expected new file mode 100644 index 0000000000..4bbd4d283a --- /dev/null +++ b/plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs.expected @@ -0,0 +1,7 @@ +newtype MyRecord a = Record + { field1 :: a + } + +blah :: (a -> Int) -> a -> MyRecord a +blah _ = Record +