Git Product home page Git Product logo

frames-beam's People

Contributors

gagandeepb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

frames-beam's Issues

Schema.hs is not picked up by Travis

/home/travis/build/gagandeepb/Frames-beam/src/UsageExample.hs:36:1: error:
    Could not find module ‘Schema’
    Use -v to see a list of the files searched for.
   |
36 | import           Schema
   | ^^^^^^^^^^^^^^^^^^^^^^^

fails to build when added as a stack dependency

upon building my project:

 Couldn't match kind ‘*’
                         with (ghc-prim-0.5.1.1:GHC.Types.Symbol, *)
          When matching the kind of ZipTypes b_names b_rs
          Expected type: b Identity
                         -> Frames.Rec.Record (ZipTypes b_names b_rs)
            Actual type: b Identity
                         -> Data.Vinyl.Core.Rec
                              Data.Vinyl.Functor.Identity (ZipTypes b_names b_rs)
         In the first argument of map, namely createRecId
          In the expression: map createRecId bQRes
          In an equation for bRecs’: bRecs = map createRecId bQRes
         Relevant bindings include
            bRecs :: [Frames.Rec.Record (ZipTypes b_names b_rs)]
              (bound at src/Frames/SQL/Beam/Postgres/Query.hs:66:5)
            join2 :: JoinQueryResults a b
                     -> FrameRec (ZipTypes a_names a_rs ++ ZipTypes b_names b_rs)
              (bound at src/Frames/SQL/Beam/Postgres/Query.hs:61:1)

using this stack.yaml

resolver: lts-11.7
packages:
- .
extra-deps:
- Frames-0.5.0
- beam-core-0.7.2.2
- beam-migrate-0.3.2.1
- beam-postgres-0.3.2.2
- vinyl-0.10.0
- Frames-beam-0.1.0.1

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

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

Does not compile

With

let

myHaskellPackageOverlay = self: super: {
  myHaskellPackages = super.haskellPackages.override {
    overrides = hself: hsuper: rec {
      htoml = super.haskell.lib.dontCheck (hself.callCabal2nixWithOptions "htoml" (builtins.fetchGit {
        url = "https://github.com/mirokuratczyk/htoml";
        rev = "33971287445c5e2531d9605a287486dfc3cbe1da";
      }) "" { });
      hasql-streams-core = super.haskell.lib.doJailbreak hsuper.hasql-streams-core;
      hasql-streams-conduit = super.haskell.lib.doJailbreak hsuper.hasql-streams-conduit;
      hasql-transaction-io = super.haskell.lib.doJailbreak hsuper.hasql-transaction-io;
      hasql-streams-pipes = super.haskell.lib.doJailbreak hsuper.hasql-streams-pipes;
      hasql-streams-streaming = super.haskell.lib.doJailbreak hsuper.hasql-streams-streaming;
      hasql-streams-streamly = super.haskell.lib.doJailbreak hsuper.hasql-streams-streamly;
    };
  };
};

in

{ nixpkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixpkgs-22.05-darwin.tar.gz")
  {
    overlays = [ myHaskellPackageOverlay ];
    config.allowBroken = true;
  }
}:

let

  pkgs = nixpkgs;

  haskellDeps = ps: with ps; [
    base
    beam-core
    beam-migrate
    beam-postgres
    text
    Frames
    template-haskell
    generics-sop
    vinyl
    process
    conduit
    monad-control
    bytestring
    scientific
    time
    uuid-types
    hspec
    hspec-core
    QuickCheck
  ];

in

pkgs.stdenv.mkDerivation {
  name = "rOnly";

  buildInputs = [
    pkgs.libintlOrEmpty
    pkgs.stack
    (pkgs.myHaskellPackages.ghcWithPackages haskellDeps)
    pkgs.darwin.apple_sdk.frameworks.Cocoa
  ];
}

I get

[nix-shell:~/Frames-beam]$ stack build
stack build
No setup information found for ghc-8.2.2 on your platform.
This probably means a GHC bindist has not yet been added for OS key 'macosx-aarch64'.
Supported versions: ghc-8.10.5, ghc-8.10.6, ghc-8.10.7, ghc-9.0.2, ghc-9.2.1, ghc-9.2.2, ghc-9.2.3, ghc-9.2.4, ghc-9.2.5, ghc-9.2.6, ghc-9.2.7, ghc-9.2.8, ghc-9.4.1, ghc-9.4.2, ghc-9.4.3, ghc-9.4.4, ghc-9.4.5, ghc-9.6.1, ghc-9.6.2

and

[nix-shell:~/Frames-beam]$ cabal build
cabal build
Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):
 - Frames-beam-0.2.0.0 (lib) (first run)
Preprocessing library for Frames-beam-0.2.0.0..
Building library for Frames-beam-0.2.0.0..
[4 of 6] Compiling Frames.SQL.Beam.Postgres.Query ( src/Frames/SQL/Beam/Postgres/Query.hs, /Users/dom/Frames-beam/dist-newstyle/build/aarch64-osx/ghc-9.0.2/Frames-beam-0.2.0.0/build/Frames/SQL/Beam/Postgres/Query.o, /Users/dom/Frames-beam/dist-newstyle/build/aarch64-osx/ghc-9.0.2/Frames-beam-0.2.0.0/build/Frames/SQL/Beam/Postgres/Query.dyn_o )

src/Frames/SQL/Beam/Postgres/Query.hs:38:18: error:
    • Couldn't match type ‘Postgres’ with ‘PgSelectSyntax’
      Expected: Q PgSelectSyntax b s (a (QExpr PgExpressionSyntax s))
        Actual: Q Postgres b s (a (QExpr Postgres s))
    • In the expression: all_ (tbl db)
      In an equation for ‘allRows’: allRows tbl db = all_ (tbl db)
   |
38 | allRows tbl db = all_ (tbl db)
   |                  ^^^^^^^^^^^^^

src/Frames/SQL/Beam/Postgres/Query.hs:52:3: error:
    • Couldn't match type ‘PgExpressionSyntax’ with ‘PgSelectSyntax’
      Expected: Q PgSelectSyntax b s (a (QExpr PgExpressionSyntax s))
        Actual: Q PgExpressionSyntax b s (a (QExpr PgExpressionSyntax s))
    • In the expression: filter_ (filterLambda) (allRows tbl db)
      In an equation for ‘allRowsWhere’:
          allRowsWhere tbl db filterLambda
            = filter_ (filterLambda) (allRows tbl db)
   |
52 |   filter_ (filterLambda) (allRows tbl db)
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Frames/SQL/Beam/Postgres/Query.hs:52:27: error:
    • Couldn't match type ‘PgSelectSyntax’ with ‘PgExpressionSyntax’
      Expected: Q PgExpressionSyntax b s (a (QExpr PgExpressionSyntax s))
        Actual: Q PgSelectSyntax b s (a (QExpr PgExpressionSyntax s))
    • In the second argument of ‘filter_’, namely ‘(allRows tbl db)’
      In the expression: filter_ (filterLambda) (allRows tbl db)
      In an equation for ‘allRowsWhere’:
          allRowsWhere tbl db filterLambda
            = filter_ (filterLambda) (allRows tbl db)
   |
52 |   filter_ (filterLambda) (allRows tbl db)
   |                           ^^^^^^^^^^^^^^

Without the jail breaks, the dependencies do not compile.

Does not install

[nix-shell:~/Frames-beam]$ stack build
stack build
No setup information found for ghc-8.2.2 on your platform.
This probably means a GHC bindist has not yet been added for OS key 'macosx-aarch64'.
Supported versions: ghc-8.10.5, ghc-8.10.6, ghc-8.10.7, ghc-9.0.2, ghc-9.2.1, ghc-9.2.2, ghc-9.2.3, ghc-9.2.4, ghc-9.2.5, ghc-9.2.6, ghc-9.2.7, ghc-9.2.8, ghc-9.4.1, ghc-9.4.2, ghc-9.4.3, ghc-9.4.4, ghc-9.4.5, ghc-9.6.1, ghc-9.6.2
[nix-shell:~/Frames-beam]$ cabal build
cabal build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: Frames-beam-0.2.0.0 (user goal)
[__1] next goal: vinyl (dependency of Frames-beam)
[__1] rejecting: vinyl-0.14.3 (conflict: Frames-beam => vinyl>=0.10 && <0.11)
[__1] skipping: vinyl-0.14.2, vinyl-0.14.1, vinyl-0.13.3, vinyl-0.13.2,
vinyl-0.13.1, vinyl-0.13.0, vinyl-0.12.3, vinyl-0.12.1, vinyl-0.12.0,
vinyl-0.11.0 (has the same characteristics that caused the previous version to
fail: excluded by constraint '>=0.10 && <0.11' from 'Frames-beam')
[__1] trying: vinyl-0.10.0.1
[__2] next goal: base (dependency of Frames-beam)
[__2] rejecting: base-4.16.4.0/installed-4.16.4.0 (conflict: vinyl =>
base>=4.7 && <4.13)
[__2] skipping: base-4.18.0.0, base-4.17.1.0, base-4.17.0.0, base-4.16.4.0,
base-4.16.3.0, base-4.16.2.0, base-4.16.1.0, base-4.16.0.0, base-4.15.1.0,
base-4.15.0.0, base-4.14.3.0, base-4.14.2.0, base-4.14.1.0, base-4.14.0.0,
base-4.13.0.0 (has the same characteristics that caused the previous version
to fail: excluded by constraint '>=4.7 && <4.13' from 'vinyl')
[__2] rejecting: base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, base-4.10.1.0,
base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0,
base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1,
base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0,
base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0,
base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from
non-upgradeable package requires installed instance)
[__2] fail (backjumping, conflict set: Frames-beam, base, vinyl)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: Frames-beam, vinyl, base

update to lts-14.1

Hi Gagandeep!
I was looking at your work, good stuff! In order to study/experiment with it I was able to update it to lts-14.1; would you be interested if I submitted the changes I have as a PR? Might help other learners like me who want to look at it.
Best,
Jorge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.