amuletml / amulet

An ML-like functional programming language
https://amulet.works/
BSD 3-Clause "New" or "Revised" License
328 stars 16 forks source link

Record type doc #303

Closed sigmasoldi3r closed 3 years ago

sigmasoldi3r commented 3 years ago

I've been looking for the Records can be extended using magic.↩︎ at https://amulet.works/tutorials/01-intro.html but the link is broken.

What is the current way to achieve it? There are join types like in Typescript?

type file <- { readAll : () -> string }
type response <- { anything : () -> string } & file
SquidDev commented 3 years ago

Ahh, that blog post is located at https://abby.how/quick/manipulating-records-in-amulet.html now. Woops, I'll update those links.

To answer your question, there's no intersection types in Amulet (as that implies subtyping). Instead you can do something like this:

type file <- { readAll : () -> string }
type response <- { file | anything : () -> string }
SquidDev commented 3 years ago

Links should now be fixed :).