Stream: beginners

Topic: Elm Roc type comparability?


view this post on Zulip Oliver Schöning (Apr 19 2022 at 18:39):

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?

view this post on Zulip Richard Feldman (Apr 19 2022 at 20:01):

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

view this post on Zulip Richard Feldman (Apr 19 2022 at 20:02):

but Roc has a bunch of different number types, whereas Elm has Int and Float

view this post on Zulip Richard Feldman (Apr 19 2022 at 20:04):

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

view this post on Zulip Oliver Schöning (Apr 19 2022 at 21:18):

Ah, thanks @Richard Feldman

view this post on Zulip Mario (Jun 17 2022 at 11:53):

@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...

view this post on Zulip Richard Feldman (Jun 17 2022 at 12:12):

tuples in Roc are now WIP https://github.com/rtfeldman/roc/issues/2935

view this post on Zulip Richard Feldman (Jun 17 2022 at 12:16):

the formatting also changed a bit, e.g.

Location :
    {
        line : I32,
        column : I32,
    }

...is now formatted as:

Location : {
    line : I32,
    column : I32,
}

view this post on Zulip Richard Feldman (Jun 17 2022 at 12:17):

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:

view this post on Zulip Folkert de Vries (Jun 17 2022 at 12:18):

newtype in haskell for opaque

view this post on Zulip Folkert de Vries (Jun 17 2022 at 12:18):

though newtype is subtle

view this post on Zulip Folkert de Vries (Jun 17 2022 at 12:18):

comparing type classes with abilities is trickier

view this post on Zulip Qqwy / Marten (Jun 17 2022 at 12:21):

Ooh! Thanks for linking to the guide. That is super helpful!

view this post on Zulip Qqwy / Marten (Jun 17 2022 at 13:21):

Folkert de Vries said:

comparing type classes with abilities is trickier

Is there a resource with more information on how abilities work somewhere?

view this post on Zulip Ayaz Hafiz (Jun 17 2022 at 13:30):

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.

view this post on Zulip Mario (Jun 17 2022 at 16:38):

If anyone wishes to update anything that's out of date, PRs welcome! https://github.com/supermario/fptransforms

view this post on Zulip Mario (Jun 17 2022 at 16:39):

@Richard Feldman I'd be fine with adding a section on opaque types / abilities with "-- No equivalent" entries in the Elm/Haskell columns :D

view this post on Zulip Richard Feldman (Jun 17 2022 at 17:13):

@Ayaz Hafiz want to do the honors? The whole Abilities implementation is all thanks to you!

view this post on Zulip Ayaz Hafiz (Jun 17 2022 at 18:23):

absolutely. Mario, i’ll send you a patch in the next couple days.

view this post on Zulip jan kili (Jun 21 2022 at 00:06):

@Richard Feldman (...tuples are coming?) :eyes:

view this post on Zulip Richard Feldman (Jun 21 2022 at 00:21):

tuples

view this post on Zulip Richard Feldman (Jun 21 2022 at 00:22):

https://github.com/rtfeldman/roc/issues/2935

view this post on Zulip jan kili (Jun 21 2022 at 04:32):

:surprise: That's... not where I expected the tuple debate to go :laughing:

view this post on Zulip jan kili (Jun 21 2022 at 04:33):

IDK SIMD; LGTM

view this post on Zulip Qqwy / Marten (Jun 21 2022 at 13:29):

I hope I did not disturb anything important :sweat_smile:

view this post on Zulip Qqwy / Marten (Jun 22 2022 at 07:27):

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} ?

view this post on Zulip Richard Feldman (Jun 22 2022 at 11:55):

nope, those are all identical at runtime!


Last updated: Jul 06 2025 at 12:14 UTC