Re:Rust 2018 is here, but what is it?
by steveklabnik on Friday December 07, 2018 @11:39AM
(#18629089)
You can use pattern matches in function signatures.
Re:Rust 2018 is here, but what is it?
by throwaway487550 on Friday December 07, 2018 @11:45AM
(#18629149)
How could I write this in Rust?
fun map f [] = []
| map f (x::xs) = (f x) :: map f xs;
And boy, no TCO. What a shame.
Re:Rust 2018 is here, but what is it?
by steveklabnik on Friday December 07, 2018 @12:05PM
(#18629338)
You can only use irrefutable patterns. You’d write this by writing a match in the body. There’s been talk of maybe supporting this directy but it’s so niche there’s not a ton of demand.
There is TCO, just not guaranteed. We’d like it; we have even reserved a keyword. Needs an RFC though.
Re:Rust 2018 is here, but what is it?
by throwaway487550 on Friday December 07, 2018 @11:42AM
(#18629122)
> Rust's traits are type-classes.
And the functor typeclass in Rust looks like...?
Re:Rust 2018 is here, but what is it?
by paavohtl on Saturday December 08, 2018 @06:23AM
(#18634795)
Rust doesn't currently have higher-kinded types, which are a separate feature from typeclasses. Implementing a true Functor trait is impossible without HKT, though the lack of it and other FP abstractions generally speaking hasn't been an issue.
Where are you missing pattern matching? The only place I can think of where it can't be used currently is the function signature. Might be hard to retrofit to the current syntax.
> Type-classes
Rust's traits are type-classes.
> first class typed channels
Why do they need to be first class? Unlike Go, Rust's type system is powerful enough that type-safe channels can be (and have been) implemented as a library. See crossbeam-channel.