Closed ghost closed 3 years ago
Nope, and that's why they create typealias:
-prefixed symbols... they are actually much more lightweight than typeclasses, as they are just strings containing a type expression.
Now I suppose you'll say that there's no way to check whether a value validates a type or or (returning a Boolean value instead of an error, like expect)... right...? 🙄
I may add an is?
predicate that returns a Boolean value depending whether a value matches a type expression or not. What do you think? I don't think there's a way to do that without using expect
within a try
.
What do you think?
EDIT Actually, maybe I can just extend type?
to work with type expressions as well.
Nope, and that's why they create typealias:-prefixed symbols... they are actually much more lightweight than typeclasses, as they are just strings containing a type expression.
Strings... Can we use strings to predecate parameter types of operator signatures? Or do you know how to do?
EDIT Actually, maybe I can just extend type? to work with type expressions as well.
type?
currently works for built-in types and ... yes you should extend or the another way to do is is?
I choose the way of extending type?
symbol.
I don't think there's a way to do that without using
expect
within atry
.
Yeah really. I don't want to use try
for easy things. I think try
increases the heaviness of the code execution.
Nope, and that's why they create typealias:-prefixed symbols... they are actually much more lightweight than typeclasses, as they are just strings containing a type expression.
Strings... Can we use strings to predecate parameter types of operator signatures? Or do you know how to do?
Pregeneration? #126 😆 (Welcome to Recursino!)
Ahhhhhhh well...
OK so... here's another two things to consider that may help you with this:
typealias:
symbols are not sealed... 😜Technically, you could reset a typealias to whatever you want, at any time!
So great! 👍
An example i designed for type pre-processing:
( typeclass thermo-enums
(str :s ==> bool :r)
(("hot" "normal" "cold") s in? @r)
) ::
( symbol temperature-type
(thermo-enums :enum ==> str :T)
(
(enum "hot" ==) ("positive" @T) when
(enum "normal" ==) ("natural" @T) when
(enum "cold" ==) ("int" @T) when
)
) ::
"cold" :current
current temperature-type 'temp-type typealias
( symbol say-me
(temp-type :value ==>)
("It is $1 . Its type is $2" value dup type 2 *mutspec/group-quote % puts!)
) ::
-3 say-me
"hot" :current
current temperature-type 'temp-type typealias
5 say-me
Outs:
It is -3 . Its type is int
It is 5 . Its type is int
However i can't complete the example because of unable to access typeclasses in operator sign. bodies. It says int
at It is 5 . Its type is int
instead of It is 5 . Its type is positive
The problem is that type can only return the primitive or dictionary type... a value can match several type expressions, type aliases and type classes: it is not possible to determine a type alias of a value, only determine if it satisfies a particular one or not.
The problem is that type can only return the primitive or dictionary type... a value can match several type expressions, type aliases and type classes: it is not possible to determine a type alias of a value, only determine if it satisfies a particular one or not.
We may get parameter types to use them in operator signatures after satisfying predecure??
Parameter types? Isn't what type aliases, type classes, etc. are for? What do you mean?
The problem is that if you take a value, on its own, and check its type, it will always be one of the primitive types...
Parameter types? Isn't what type aliases, type classes, etc. are for? What do you mean?
The problem is that if you take a value, on its own, and check its type, it will always be one of the primitive types...
I mean if we use typeclasses or aliases as parameter types one will should access that types. Maybe inputs
or parameters
quotes would be used for this purpose.
We could expose an inputs
dictionary inside the body of operators containing information about the input values, as described here.
In this way it would be possible to access the typeclass that matched (if any), and of course the primitive type, but not a type alias: type alias are immediately converted into the corresponding type expressions and they could be nested in other aliases, so even within the same type expression there could be several aliases matching...
In this way it would be possible to access the typeclass that matched (if any), and of course the primitive type, but not a type alias:
I think so
Checked the current implementation and I would have to change quite a lot of things in the expectation code to keep track of the typeclasses that validated each input.
Not going to implement it for now, there are/will be ways to check if a value matches a type/typeclass/typealias anyway. Less immediate, but tbh not sure how useful this is ultimately to the language.
"a" typealias:anynum
-result>int|flt
instead of boolean value.It seems not working as typeclasses. Because typeclasses returns boolean values when they had been used for expectation.