
On Mon, 23 Apr 2018, Tom Ellis wrote:
I had an error in what I said and also it was imprecise. It's `Res (Cols s a)` which is `a`, but only in the cases where you're actually going to use it, and the compiler cannot take that into account when solving the constraint. Anyway, as Li-yao Xia points out in a sibling message, the type variable `s` in not constrained and therefore it seems impossible to solve.
Thanks Tom for your reply. In this case the error is: ``` • Couldn't match type ‘a’ with ‘Res (Cols s0 a)’ ‘a’ is a rigid type variable bound by the type signature for: list :: forall s a. (Result (Cols s a), Columns (Cols s a)) => Table a -> IO [a] at src/Hedger/Backend.hs:24:1-69 Expected type: selda-0.1.12.1:Database.Selda.Backend.Internal.SeldaM [a] Actual type: selda-0.1.12.1:Database.Selda.Backend.Internal.SeldaT IO [Res (Cols s0 a)] • In the second argument of ‘($)’, namely ‘query (select table)’ In the expression: withDB $ query (select table) In an equation for ‘list’: list table = withDB $ query (select table) • Relevant bindings include table :: Table a (bound at src/Hedger/Backend.hs:25:6) list :: Table a -> IO [a] (bound at src/Hedger/Backend.hs:25:1) | 25 | list table = withDB $ query (select table) ```
Thanks, but could you send a full working version that includes a definition of `list`? I can't replicate what you've done on my end.
I have pushed the repo to Github: https://github.com/waiting-for-dev/hedger Important code is in `src/Hedger/` directory. `Backend.hs` is where `list` is defined. Right now it has its type signature commented out so that it compiles thanks to `AllowAmbiguosTypes` and `FlexibleContexts`. `Category.hs` has the function `listCategories` which uses `list`. Anyway, from `ghci` one can just call `list categories` or `list expenses`. There is also a helper function `addCategory` to add a category record just providing its name (from `ghci`, `OverloadedStrings` must be loaded). In `Migration.hs` is where `categories` and `expenses` tables are created. Marc Busqué http://waiting-for-dev.github.io/about/