[Haskell-cafe] Why can't I bind unlifted values at the top level?
Ben Gamari
ben at smart-cactus.org
Sat Jan 21 19:00:47 UTC 2023
Tom Ellis <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> writes:
> I can't bind unlifted values at the top level:
>
> foo = (##)
>
> Top-level bindings for unlifted types aren't allowed: foo = (##)
>
> I can understand why I shouldn't be able to bind unlifted
> *expressions* at the top level
>
> foo = complicatedExpression
>
> Perhaps complicatedExpression doesn't terminate! But why can't I bind
> _values_, i.e. things that are already evaluated? Given that (##) and
> proxy# already exist at the top-level it seems reasonable that I
> should be allowed to define my own!
>
There are a few things going on here. The case you give here is not just
unlifted but also unboxed (namely, being an unboxed tuple). It's hard to
see how top-level binding of unboxed values would work operationally
(e.g. how is the garbage collector to know how to trace this object,
given that unboxed objects have no object header?).
However, I suspect you do have a point when it comes to unlifted data
constructors. I think it would be fine to allow an application of a
data constructor of an unlifted type on the top-level:
type UMaybe :: Type -> UnliftedType
data UMaybe a = UNothing | UJust a
x :: UMaybe Int
x = UJust 42
Perhaps you could open a ticket for this?
Cheers,
- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20230121/f6d1c663/attachment.sig>
More information about the Haskell-Cafe
mailing list