Closed chshersh closed 6 years ago
Why?
fun replace(needle: String, replacement: String, haystack: String) { .. }
Shorter.
Does being shorter justify introducing even more obscure syntax? Named
is immediately understandable, :=
is not.
Cooler.
This is subjective.
Fancier.
And that's hardly an advantage.
Looks more similar to function signatures of imperative languages, like this:
Now that is a good point, but :=
looks like variable assignment! Had I the opportunity to use :
without =
, I'd definitely do that.
I guess "shorter" is a strong point since the library is meant to be used pervasively, but I'm not sold on :=
. Maybe some other character sequence would do.
but
:=
looks like variable assignment!
That's a fair point! I can propose other alternatives:
:::
=:
:-
-:
:=:
:-:
:>
:#
:@
Had I the opportunity to use : without =, I'd definitely do that.
Could you overload :
operator like you did with /
and *
in o-clock
?
Oh, also looks like :=
(and a lot of many others) are not even impossible to use...
I decided that I don't like any of those options.
We could use Text : "foo"
if we had -XOverloadedStringsDataKinds :trollface:
no, nevermind, [*]
is uninhabited
I'd like to be able to write "foo" : Text
. This would be achievable with the following definition of :
(approximately):
type family ColonK k1 k2
type instance ColonK a [a] = [a]
type instance ColonK Symbol Type = Type
type family (a :: k1) : (b :: k2) :: ColonK k1 k2
type instance name : ty = Named ty name
type instance x : xs = x ': xs
Unfortunately, :
is built-in syntax and can't be used as a regular operator with TypeOperators
.
-XOverloadedDataKindsColonOperator
anyone?..
Authors of gdp
paper use the following operator for their Named
:
I'm not sure, what is better: use the same operator so people can be familiar with concept through multiple sources (and no collisions) or use different operator to show that this is actually is different name.
P.S. I'm still hoping that -XOverloadedDataKindsColonOperator
will be implemented some day... Probably with better name.
Like
:=
. For example, instead of this:users can write