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

Nestable type definitions #401

Open
jckarter opened this issue Oct 9, 2012 · 2 comments
Open

Nestable type definitions #401

jckarter opened this issue Oct 9, 2012 · 2 comments

Comments

@jckarter
Copy link
Owner

jckarter commented Oct 9, 2012

It would be sort of convenient to be able to define variant or newtype member types in-line in a variant or newtype definition, for instance:

variant List[T] (record Nil (), record Cons[T] (car:Pointer[List[T]], cdr:T));

newtype BigMac = private record BigMacImpl (secretSauce:SecretSauce);
@ghost
Copy link

ghost commented Nov 19, 2012

Is having multiple statements/definitions on one line a 'good' thing? Realistically you could only fit a couple of in-line record definitions on the same line as the top level definition before it starts to get ugly. Is there another language that uses this form successfully?

@jckarter
Copy link
Owner Author

In traditional Hindley-Milner type systems, variant members are defined in-line as part of the variant type, so the idea was to allow those sorts of definitions, like data Maybe t = Nothing | Just t, where the component tags logically make sense as part of the type. Clay's arrangement that variants are composed over independent types is somewhat unusual, but I think Scala's case classes are roughly comparable, though IIRC Scala doesn't provide a sugar to define a type with all of its subtypes.

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