haskell-beam / haskell-beam/beam

insertExpressions cannot `val_` lexical captures

Open
#364 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Haskell
Stars
635
Forks
193
PR merge metrics
No merged PRs in 30d

Description

Maybe I'm coming at this the wrong way, but the following does not work:

```haskell
insertStuff :: Text -> [(Address, Text)] -> Pg ()
insertStuff name addresses = runInsert $ insert (tableSelector db) $ do
let modelize (addr, url) = Model
default_ -- UUID
default_ -- LocalTime
default_ -- LocalTime
(val_ $ addressToText addr)
(val_ name)
(val_ url)
(val_ Nothing)
insertExpressions $ modelize <$> addresses
```
It fails with:
```
Couldn't match type ‘Columnar
f0 uuid-types-1.0.3:Data.UUID.Types.Internal.UUID’
with ‘QGenExpr ctxt0 be0 s0 a1’
Expected type: C f0 uuid-types-1.0.3:Data.UUID.Types.Internal.UUID
Actual type: QGenExpr ctxt0 be0 s0 a1
The type variables ‘f0’, ‘ctxt0’, ‘be0’, ‘s0’, ‘a1’ are ambiguous
...
|
178 | default_
| ^^^^^^^^
```
But if I rid myself of lexical captures, it is happy:
```haskell
insertStuff :: Text -> [(Address, Text)] -> Pg ()
insertStuff name addresses = runInsert $ insert (tableSelector db) $ do
let modelize name' (addr, url) = Model
default_
default_
default_
(val_ $ addressToText addr)
(val_ name')
(val_ url)
(val_ Nothing)
insertExpressions $ modelize name <$> addresses
```

Should this be the case? What am I encountering?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.