I’m looking at Roc every now and then while working on some projects and would like to know how the possibilities are of translating types from one language to the other. Looks to me like going from Roc to Elm would be hard because of the tagged unions but taking Elm types should be easy to transpile into Roc?
actually I think numbers would be the bigger problem - closed tag unions in Roc should be straightforward to translate to/from Elm custom types, and if you had any open tag unions, you could presumably close them before translating them to Elm
but Roc has a bunch of different number types, whereas Elm has Int
and Float
also Elm's Int
is technically an F64
at runtime because it compiles to JavaScript and that's how JS works, so it's possible to get an Int
from Elm that's Infinity
or NaN
Ah, thanks @Richard Feldman
@Oliver Schöning have been keeping an equivalencies doc here: https://fptransforms.netlify.app/transformations.html might find it helpful. Unsure if Roc is further changed since last updates by Richard tho...
tuples in Roc are now WIP https://github.com/rtfeldman/roc/issues/2935
the formatting also changed a bit, e.g.
Location :
{
line : I32,
column : I32,
}
...is now formatted as:
Location : {
line : I32,
column : I32,
}
there's also new syntax for Opaque Types and Abilities, but I guess there isn't a section on the equivalents of those in Elm or Haskell in there :big_smile:
newtype
in haskell for opaque
though newtype is subtle
comparing type classes with abilities is trickier
Ooh! Thanks for linking to the guide. That is super helpful!
Folkert de Vries said:
comparing type classes with abilities is trickier
Is there a resource with more information on how abilities work somewhere?
Richard has a proposal document for abilities here: https://docs.google.com/document/d/1kUh53p1Du3fWP_jZp-sdqwb5C9DuS43YJwXHg1NzETY/edit
The current implementation is mostly the same. It's the most recent feature so a lot of things are still TBD.
If anyone wishes to update anything that's out of date, PRs welcome! https://github.com/supermario/fptransforms
@Richard Feldman I'd be fine with adding a section on opaque types / abilities with "-- No equivalent" entries in the Elm/Haskell columns :D
@Ayaz Hafiz want to do the honors? The whole Abilities implementation is all thanks to you!
absolutely. Mario, i’ll send you a patch in the next couple days.
@Richard Feldman (...tuples are coming?) :eyes:
https://github.com/rtfeldman/roc/issues/2935
:surprise: That's... not where I expected the tuple debate to go :laughing:
IDK SIMD; LGTM
I hope I did not disturb anything important :sweat_smile:
Richard Feldman said:
tuples in Roc are now WIP https://github.com/rtfeldman/roc/issues/2935
Question: Is there a difference in runtime behavior (time/memory usage, etc.) between, say, Pair a b
and (a, b)
AKA { 0: a, 1: b}
?
nope, those are all identical at runtime!
Last updated: Jul 06 2025 at 12:14 UTC