Skip to content

Commit

Permalink
Follow-up to #406
Browse files Browse the repository at this point in the history
There was one place where #406 forgot to check for higher-rank types:
the types of data constructors. Easily fixed.
  • Loading branch information
RyanGlScott committed Nov 2, 2019
1 parent b0e0faf commit dff1f74
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Data/Singletons/Single/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ singCtor dataName (DCon con_tvbs cxt name fields rty)
sName = singDataConName name
sCon = DConE sName
pCon = DConT name
checkVanillaDType $ DForallT ForallInvis con_tvbs $ ravel types rty
indexNames <- mapM (const $ qNewName "n") types
kinds <- mapM promoteType types
rty' <- promoteType rty
kinds <- mapM promoteType_NC types
rty' <- promoteType_NC rty
let indices = map DVarT indexNames
kindedIndices = zipWith DSigT indices kinds
args = map (DAppT singFamily) indices
Expand Down
1 change: 1 addition & 0 deletions tests/SingletonsTestSuite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ tests =
, compileAndDumpStdTest "T376"
, compileAndDumpStdTest "T378a"
, compileAndDumpStdTest "T401"
, compileAndDumpStdTest "T401b"
, compileAndDumpStdTest "T402"
, compileAndDumpStdTest "T410"
, compileAndDumpStdTest "T412"
Expand Down
13 changes: 13 additions & 0 deletions tests/compile-and-dump/Singletons/T401b.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Singletons/T401b.hs:0:0: error:
`singletons` does not support higher-rank `forall`s
In the type: (forall a_0 . a_0) -> T_1

|
5 | $(singletons [d|
| ^^^^^^^^^^^^^^...

Singletons/T401b.hs:0:0: error: Q monad failure
|
5 | $(singletons [d|
| ^^^^^^^^^^^^^^...
8 changes: 8 additions & 0 deletions tests/compile-and-dump/Singletons/T401b.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module T401b where

import Data.Singletons.TH

$(singletons [d|
newtype T where
MkT :: (forall a. a) -> T
|])

0 comments on commit dff1f74

Please sign in to comment.