Skip to content

Schema code should come into scope in the module calling genBeamSchema and not be put in a separate file/module #17

@gagandeepb

Description

@gagandeepb

The idea: A call to genBeamSchema currently creates a new file named NewBeamSchema.hs in the src directory (relative to project root) with generated code corresponding to the database schema in it. This module then needs to get imported in the calling module in order to be used further.

It has been suggested that the generated code should come into scope in the calling module directly, and not go into a separate module of it's own. The primary difficulties in being able to do so are the following:

  • The generated code is a full Haskell module in String form. In order to splice it into the calling module would require a transformation from String to some sort of Intermediate Representation (IR) and from the IR to TemplateHaskell's [Dec]. The only way I know of doing this via the haskell-src-meta library. Initial attempts to use this approach have failed (I got a partially parsed output with a "Parse Error" when I last tried), but it is possible that I'm doing something wrong.

  • The second difficulty has more to do with the user experience of the library. Assuming we succeed in the above attempts at splicing the generated code into the calling module; the user would then need to pass in compiler flags to inspect the generated code in order to know what declarations to pass onwards to deriveGeneric and deriveVinyl. This could possibly be an inconvenience to some users.

Having said the above, any help/feedback with regards to this issue will be appreciated.

cc @ocramz

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions