Closed ghost closed 3 years ago
Uhm... yes, two possibilities here:
typealias
, and again in this case not require the body quotation.Something like this:
(
typealias my-num
(int|flt ==> bool)
)
Note that in this case there wouldn't be any need for capturing symbols in the signature either, I guess.
there wouldn't be any need for capturing symbols in the signature either, I guess.
Typealiases would be extra option and truthly you don't wanna use all builtin types(for example) within operator signatures, this would be nasty.
I prefer (builtin :b)
to (int|float|string|...)
.
allow you to omit the body quotation in typeclass operator (and in that case return true if the input is processed correctly)
This method looks more perfect. Because of eval
performings. Do you know lifters? You may see them in nim. There is possible to make them in min, too. typeclass
and typealias
keywords would be nightmare of lifters. Because two symbols means extra handlings for lifters: "Lifter: Hmm... Which one must i choose of them? typeclass
or typealias
?"
Lifters? You mean lambda lifting?
But yes maybe a typealias
would be a lightweight operator to rename type unions, or even standard types... it could be useful in certain contexts perhaps.
Lifters? You mean lambda lifting?
Yep see #123 (there is an example about the topic)
I was thinking of allowing an even shorter syntax for type classes' instead of introducing type aliases.
This would keep the same type of operator (typeclass) for essentially the same thing (defining a type constraint).
I thought of an even shorter syntax:
(
typeclass warm-temperature
twenty-plus&thirty-minus
) ::
where for example twenty-plus
and thirty-minus
are type classes defined as:
(
typeclass twenty-plus
(int :t ==> book: :r)
(t 20 >= @r)
) ::
(
typeclass thirty-minus
(int :t ==> book: :r)
(t 30 <= @r)
) ::
Thoughts? Actually I could just use a symbol, but because the result is still a typeclass, I prefer to keep the same type of operator with a simplified syntax.
The obvious alternative would be something like:
'twenty-plus&thirty-minus 'warm-temperature typealias
Much simpler to implement... the only thing that I don't like is that it would return typeclass:warm-temperature
. But it's much shorter.
Which syntax would you like the most?
I'd like two of syntaxes(all)! 🙃
Well, the typealias
syntax won. Very lightweight implementation, and you can potentially keep creating aliases of aliases and they will be resolved hopefully (and yes of course there's also possibility of infinite recursion if you are not careful).
In the end it generates a special typealias:
symbol that is set to a string corresponding to the specified type expression. Then all lookups are performed in expects and operator signatures as needed.
Did some quick tests and it seems to work alright, now I just need to document it.
Implemented in v0.32.0.
Above signature seems extra operations that does. Only one must control the value for
int
orfloat
. Its needless part for me:true @r
-> It may hinder execution speed of code.