How do I make a constraint tuple in Core?

Ryan Scott ryan.gl.scott at gmail.com
Tue Jun 19 13:53:20 UTC 2018


I'm currently working on some code in which I need to produce a Core Type
that mentions a constraint tuple. I thought that there must surely exist
some way to construct a constraint tuple using the GHC API, but to my
astonishment, I could not find anything. The closest thing I found was
mk_tuple [1], which gives you the ability to make boxed and unboxed tuples,
but not constraint tuples.

I then thought to myself, "But wait, PartialTypeSignatures has to create
constraint tuples, right? How does that part of the code work?" To my
horror, I discovered that PartialTypeSignatures actually creates *boxed*
tuples (see mk_ctuple here [2]), then hackily treats them as constraint
tuples, as explained in Note [Extra-constraint holes in partial type
signatures] [3]. I tried reading that Note, but I couldn't follow the
details.

Is there a simpler way to create a constraint tuple that I'm not aware of?

Ryan S.
-----
[1]
http://git.haskell.org/ghc.git/blob/676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9:/compiler/prelude/TysWiredIn.hs#l810
[2]
http://git.haskell.org/ghc.git/blob/676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9:/compiler/typecheck/TcBinds.hs#l1036
[3]
http://git.haskell.org/ghc.git/blob/676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9:/compiler/typecheck/TcHsType.hs#l2367
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20180619/b6bf5e4b/attachment.html>


More information about the ghc-devs mailing list