Closed clintonmead closed 5 years ago
On some further investigation it seems like I'm not the first to think of this style of transformation. coyoneda has a similar basic idea, although my approach doesn't require a separate representation (so should have a zero or low runtime cost for the abstraction), also doesn't need explicit wrapping/unwrapping, and extends to Applicatives and Monads.
Sounds interesting Clinton, what kind of time are you thinking? You might need to introduce the FP concepts you want to talk about as I don't think everyone at the meetup will have FP background (it's a real mix).
I'll get back to you with a date soon
Sounds interesting Clinton, what kind of time are you thinking? You might need to introduce the FP concepts you want to talk about as I don't think everyone at the meetup will have FP background (it's a real mix).
Hrmmm, good point about the FP intro. Perhaps I'll put together a 5-10 minute example of Monad usage (perhaps with a SafeNum
How long it takes depends on how much people want to explore/ask questions, but it's better if people do, but I'm guessing 30 minutes to an hour. Might have a better idea when I clean up and comment the code. There's about half a dozen "tricks" that probably need the rationale behind them explained, most simple but some a bit more involved. For example there's one part which is just getting the typechecker to work with me, and I've tried to clean it up but then it just won't typecheck. I don't know why it doesn't typecheck when I clean it up and why it does when I leave it how it is (as they seem pretty similar to me) but I haven't got much of a feel of the Rust typechecker yet as I've only bashed it for a day over the weekend.
Might be best to put me last so I don't hold up another speaker if there's lots of questions.
Hi @clintonmead, would Monday the 17th of June work for you?
@bitshifter if I'm the second talk that should be fine (I've got a weekly work meeting with our UK team 5:30-6pm), so should be there by 6:30 but might be more like 7 if it runs overtime
Actually we're going to push this back to the 24th of June so there's a bit more time, does that still work for you?
Perfect the extra week will give me a bit of extra time to put it together.
Same thing applies with the Monday meeting though so just put me last and it'll be fine.
Hi Clinton, would you like to provide a brief summary of your talk and bio. It's not at all mandatory, just something I did last time that I think was useful for attendees. E.g. from last meetup https://www.meetup.com/Rust-Sydney/events/258785543/, could be a lot briefer than that and totally fine if you'd rather not. The new meetup description is here https://www.meetup.com/Rust-Sydney/events/262194894.
Will do. Is it okay if I put it together over the weekend? At that point I'll have a more complete idea of what I want to cover.
Yep, no problem
Thanks for the talk Clinton, feel free to post links to your code and/or slides on the event page for anyone who is interested https://www.meetup.com/Rust-Sydney/events/262194894/
Hi All
I'm relatively new to Rust. I came to the March meetup however the first time I actually sat down and started writing some code in it was this weekend, and I just saw your email about talks.
I have played with Haskell quite a bit and I have a full time role in C#. A summary of me and my projects can be found at clintonmead.github.io.
I gave a talk at FP-Syd in November called "Type Classes in C#". Unfortunately, the guts of that talk was a live coding demonstration and there's no video, but perhaps the demostration code using the library may be of some small insight.
But in any case in attempt to learn Rust in some anger I've managed to implement the beginnings of such an approach in Rust, implementing Functor in Rust. It should run also on Rust stable, it doesn't need any extensions.
My library allows me to write something like:
Note above that
TFunctor<?>
is not valid rust, as we don't have higher kinded types, so I encode this in a different way, but in a way so that:compiles and runs quite happily as long as "Option" implements Functor, and
f
andg
are appropriate (I knowmap2()
is silly, as you should just compose the functions, but it's just an illustrative example). We can effectively pretend we've got higher kinded types even though the actual types and traits going on under the hood are are slightly more ugly.I have done a scan of the existing crates and there's a few that implement type classes like Functor and Monad, but from what I've seen (and I may be wrong here) none of them allow you to write functions which abstract over Functor/Monad. As in, I couldn't seem to work out how to write
map2
with these libraries. I could only writemap2
for a particular instance of a Functor type, i.e. separatemap2
forOption<T>
andVec<T>
. Although perhaps I've missed something here, and it's quite possible I'm reinventing the wheel here so if so please point it out as I may be reinventing it poorly.But I'm happy to put one together a talk for mid June, two weekends should be plenty of time to flesh this out as long as I don't hit any snags.
Although at that point I'd only have three weeks experience with Rust, so I might be asking more questions to the audience than they are asking me. However, as I've done this in C# and so far it's actually easier in Rust I think I'll be able to piece something together.
The talk itself shouldn't take long (there's just a few type tricks to show) but I think it's better to demonstrate it with a lot of examples and have a Q&A style feedback to get the feel of it. The talk at FP-Syd was around 40 minutes including Q&A, but that was with C# which a lot of people weren't familiar with so using Rust at a Rust meetup might make things easier to understand.
So if this is interesting to people I'm happy to be pencilled in for a talk. I'll try to upload some code over the weekend so you can have a more concrete idea of what I'm talking about.