Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generation of tuple instances for FromRow with huge arities using TH macro #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikita-volkov
Copy link

This macro is tested to work fine in my personal projects. But after spending an hour trying to integrate it into the maze of internal cyclic dependencies of "postgresql-simple" I gave up. Anyway, I'm still posting this for you to catch on with the integration work.

@lpsmith
Copy link
Owner

lpsmith commented Nov 30, 2013

Looks good, I'll probably merge this when I get around to fixing it.

I suspect that you don't really need to change the .hs-boot files at all. Those don't include any definitions, just types, and only need to include enough types and instances to break the type-checking cycle, not every type and instance exported from a module.

@lpsmith
Copy link
Owner

lpsmith commented Nov 30, 2013

Ok, looking at it again you do need to tweak the .hs-boot files a bit. I'll look into it at some point.

@lpsmith
Copy link
Owner

lpsmith commented Dec 21, 2013

Ok, I did look at it a bit just now, for probably just over an hour. I must admit, I'm as confused as you are. GHC isn't producing very helpful error messages on this one.

I suspect it's some kind of special interaction between Template Haskell and recursive modules, but I haven't found any write up of these issues. Although the wiki hints that maybe protocol-buffers was up against a similar-ish issue? I'm not sure.

@nikita-volkov
Copy link
Author

A pity.

@dzhus
Copy link
Contributor

dzhus commented Feb 9, 2014

Care to publish it as a separate package? Being able to use native tuples for n > 8 would be splendid. Here's what I've been using so far:

-- | Works almost like '(:.)' for 'ToField' instances. Start with `()`
-- and append as many fields as needed:
--
-- > () :* f1 :* f2 :* f3
--
-- Initial `()` saves the type hassle.
data a :* b = a :* b deriving (Eq, Ord, Show, Read)

infixl 3 :*

instance (ToRow a, ToField b) => ToRow (a :* b) where
    toRow (a :* b) = toRow $ a :. (Only b)

@nikita-volkov
Copy link
Author

@dzhus I don't see much reason to. It really should be in the postgresql-simple project. You have my confirmation if you intend to do it yourself however.

It should also be noted that integrating the code in the associated commit into any project is seamless.

lpsmith added a commit that referenced this pull request Mar 22, 2014
Closes #61 and #91.  See #61 in particular for a discussion of the design
@lpsmith
Copy link
Owner

lpsmith commented Sep 7, 2014

"Closes #91" in the commit above is a typo, unfortunately one that's not easily corrected. That should have been "closes #99".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants