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

Linear fields in NP #174

Open
alt-romes opened this issue Oct 11, 2023 · 0 comments
Open

Linear fields in NP #174

alt-romes opened this issue Oct 11, 2023 · 0 comments

Comments

@alt-romes
Copy link

Hello!

I was hoping to replace my own generic heterogeneous list by sop-core's n-ary products NP, however, I realized I am not yet able to do this since the fields of NP are not linear.

Do you think we might have instead:

data NP :: (k -> Type) -> [k] -> Type where
  Nil  :: NP f '[]
-  (:*) :: f x -> NP f xs -> NP f (x ': xs)
+  (:*) :: f x %1 -> NP f xs %1 -> NP f (x ': xs)

In theory, this would only affect LinearType users of sop-core who use an NP linearly, which I reckon are not many, as otherwise all datatype constructors have linear components instead of unrestricted ones by default.

I would additionally argue that NP having linear fields is something that wasn't previously considered, as the first commit defining NP is from 2014, when LinearTypes were nowhere in sight, and was already using the GADTSyntax with unrestricted arrows.

Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant