Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions plugins/hls-tactics-plugin/test/GoldenSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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
Expand Down
7 changes: 7 additions & 0 deletions plugins/hls-tactics-plugin/test/golden/NewtypeRecord.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
newtype MyRecord a = Record
{ field1 :: a
}

blah :: (a -> Int) -> a -> MyRecord a
blah = _

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
newtype MyRecord a = Record
{ field1 :: a
}

blah :: (a -> Int) -> a -> MyRecord a
blah _ = Record