Should it be possible to use a wildcard inside an opaque type? This feels like something I should be able to do. I understand I can use a type variable, but that seems unnecessary.
module [Custom]
Custom := {
number : Frac *
}
── WILDCARD NOT ALLOWED HERE in example.roc ────────────────────────────────────
The definition of Custom includes a wildcard (*) type variable:
4│ number : Frac *
^
Opaque type definitions may not use wildcard (*) type variables. Only
named type variables are allowed.
I think we should just remove wildcards and make this whole class of edge cases disappear
And then the answer is that you need to use a variable, because that ensures that all type cardinality is exposed outside of types
Otherwise, the usage of Custom
sans type args doesn't always mean that Custom
is a static type
Which seems like a trust issue
Even without removing wildcards, I still think you should need to write
Custom frac := {
number : Frac frac
}
and use it as Custom *
or Custom _
or Custom frac
I've currently just used a concrete type F32
, and expect my API consumers to convert to that. Minor inconvenience if they have a Dec
or F64
That's probably fine
Why not F64? Seems constrictive to use the smaller float type
I want a floating value in the range 0-1
I definitely don't need an F64
precision
Oh, yeah, makes sense
Last updated: Jul 06 2025 at 12:14 UTC