Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert and forall in record #41

Open
safareli opened this issue Apr 10, 2018 · 2 comments
Open

insert and forall in record #41

safareli opened this issue Apr 10, 2018 · 2 comments
Labels
status: needs more info This issue needs more info before any action can be done.

Comments

@safareli
Copy link

safareli commented Apr 10, 2018

If i have forall in record then you can't insert

module Main where

import Prelude

import Control.Monad.Eff (Eff)
import Data.Record (insert)
import Data.Symbol (SProxy(..))
import Type.Row (class RowLacks)

type ConfigR r = (baz :: forall a. Array a | r)
type Config r = Record (ConfigR r)

add
  :: forall r
  . RowLacks "fiz" (ConfigR r)
  => Config r
  -> Config ( fiz :: String | r)
add c = insert (SProxy :: SProxy "fiz") "foo" c

error is:

  No type class instance was found for

    Prim.Union ( baz :: forall a. Array a
               | r4
               )
               ( fiz :: Entry
               )
               ( fiz :: t5
               | t6
               )

Any explanation of why it happens?

I guess if you have forall in record compiler can't calculate Union for it

@natefaubion
Copy link
Contributor

You have to propagate the Union constraint, I believe. This is part of why it would be nice to have a real Prim.Row.Lacks constraint.

@safareli
Copy link
Author

safareli commented Apr 10, 2018

@natefaubion

add
  :: forall r
  . RowLacks "fiz" (ConfigR r)
  => Union (ConfigR r) ( fiz :: String) (fiz :: String | r)
  => Config r
  -> Config (fiz :: String | r)
add c = insert (SProxy :: SProxy "fiz") "foo" c

added this Union instance but still get same error

@JordanMartinez JordanMartinez added the status: needs more info This issue needs more info before any action can be done. label Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info This issue needs more info before any action can be done.
Projects
None yet
Development

No branches or pull requests

3 participants