amuletml / amulet

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

Record type doc #303

Closed sigmasoldi3r closed 2 years ago

sigmasoldi3r commented 2 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 2 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 2 years ago

Links should now be fixed :).