Hey! is anyone familiar with the reason for why newtype constructors must be linear? e.g.
{-# LANGUAGE LinearTypes #-}newtypeUrawhereUr::a->Ura
doesn't work
[1 of 1] Compiling Main ( linear.hs, interpreted )
linear.hs:4:3: error:
• A newtype constructor must be linear
• In the definition of data constructor ‘Ur’
In the newtype declaration for ‘Ur’
|
4 | Ur :: a -> Ur a
| ^^^^^^^^^^^^^^^
Failed, no modules loaded.
Hey! is anyone familiar with the reason for why
newtype
constructors must be linear? e.g.doesn't work
this hints to me that linear types also carry some runtime info?
crazy
or perhaps they didn't want to limit their possibilities (in some way??) for implementation details in the future, and so forbade this for that reason
given that you can't write an implementation for a constructor this seems like something that should be implicit
wdym by implicit?
well that they are linear by default
if you write
data Bla a = MkBla a
,MkBla
is linear by defaulthmhm
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0111-linear-types.rst#unrestricted-newtypes
whoops
huh!