haskell-beam / haskell-beam/beam
Problematic `Nullable` for sub beams
- Dominant language
- Haskell
- Stars
- 635
- Forks
- 193
- PR merge metrics
- No merged PRs in 30d
Description
When using a sub-beam that can be made null as a whole, it generates several problems, for example
```
type Foo = FooT Identity
data FooT = Foo
{ _inside :: Inside (Nullable f)
} deriving(Generic)
type Inside = InsideT Identity
data InsideT = Inside
{ _moo :: C f Int
} deriving(Generic)
instance Beamable FooT
instance Beamable InsideT
deriving instance Show Inside
deriving instance Show Foo <----------- WON'T COMPILE, no Show instance for `InsideT (Nullable Identity)`
...
update fooTable
( \FooT{..} ->
[ _inside <-. val_ (Just moo) <------------ WON'T COMPILE, Couldn't match type `ReceiptValueT (Nullable Identity)`
] with `Maybe ReceiptValue`
)
( \FooT{..} -> val_ True
)
```
There are workarounds to these problems, but they are messy or require boilerplate (or maybe am I missing something?).
Maybe using a type function `Columns` (`Cs`), similar to `Columnar`, could help to fix/ease these issues?
Haven't checked, but something like:
```
type family Columns where
Columns (Nullable Identity) a = Maybe (a Identity)
Columns f a = a f
```
? (That wouldn't fix the second problem though)
Maybe if `Columns` looks too similar to `Column`, it could be name `ColumnGroup` (`CG`) instead.
What are your thoughts on this?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.