I’m seeing some compiler hangs and just want to verify some assumptions. Are cycles in module imports allowed? How about cycles in data structure definitions?
cycles in imports aren't allowed
cycles in type aliases are only allowed within tag unions
as far as I know they aren't allowed anywhere else!
cool cool cool. Would you expect an import cycle to have given an error right now or is that a TODO? This is in platform code for rbt so maybe it’s being special-cased somehow?
yeah we have an explicit error for that one
with the fancy box art like Elm does :big_smile:
I think we have a general problem in file loading for "file not found" leads to a hang
I think the reason for this is that instead of a worker reporting that it finished and failed, it instead doesn't report at all - so other worker(s) wait for it forever
cool. I bet I can smoosh all these data types into one module and be fine
as far as the other thing, the current design for rbt has Job -> Command -> Tool -> Job. Reckon that can be accommodated or nah? Not familiar enough with the tagged stuff yet to know if it’s reasonable
anything you can do with an ADT you can do with a closed tag union, so should be fine!
phantom types currently work a little differently, but I assume they won't come up here
well, those 3 types are not in the same union. Am I understanding that’s required?
nah, so like
in Elm you'd write type Result ok err = Ok ok | Err err
and in Roc you'd write Result ok err : [ Ok ok, Err err ]
in either case you still do Ok 5
and Err "blah"
to make one, and you pattern match to destructure them in the same way
you can use tags in other ways than this, but this is how to use them to basically be ADTs
so an easy way to get started with them is to write what you'd write in Elm, then do the syntactic translation I showed above, and everything will work pretty much the same way you're used to unless you want to make a recursive one or a phantom type! :big_smile:
got it. Here's where I've ended up. Do you see anything in this module that would make this error happen? (I figure you might since we were looking at it yesterday) https://github.com/rtfeldman/rbt/pull/15#issuecomment-953756395
ahhh I think this might be https://github.com/rtfeldman/roc/issues/1642
try defining Tool
higher in the file than Command
and Command
higher than Job
ahh, ok. It happens when they’re tag unions too. I guess they use the same mechanism?
oh so Foo : ...
is Roc's syntax for type aliases - it's equivalent to type alias Foo = ...
in Elm
so all of those type definitions involving tag unions are type aliases :big_smile:
that's what I thought. OK, let's see how far I can get now :smiling_devil:
Last updated: Jul 06 2025 at 12:14 UTC