Follow

the one big thing i do like about oop languages is how there's so many places to stuff and bind names

functional languages feel like they have to jump through a lot of hoops and silly names to solve this

what's mappend, what's fmap, what's this hungarian notation MFC rubbish

do some type-directed function dispatch before blowing up

· · Web · 2 · 0 · 3

In the same vein, it's a bit of a shame that every collection type has to declare its own empty value.

Obviously, an empty list is different from an empty tree and different from an empty `Maybe` and so on.

However this feels pretty much like a polymorphic value. If you do type-directed name clarification you can call all the empty value constructors one thing as a convention and then (get this) you understand from context which one you meant, same as how mempty works, except not really polymorphic.

I've discovered Idris does type-directed function lookup, lmao.

@trickster wait, why not just make a typeclass that provides a polymorphic `empty`? then you have an actual thing that represents an empty generic collection, rather than your convention.

@Vierkantor Aesthetically, you still need to call the actual value constructor of the instance something unique, and one of the niceties of this is that you don't have to, you can just call them all `Nil` or w/e.

That aside, this flows naturally from the top-post feature (type dispatched functions) because value constructors are (at least) conceptualized as functions. The idea that this should work for nullary constructors which are decidedly not functions is what prompted the second post.

@Vierkantor of course, the benefit of your suggestion is that i could do it here and now without waiting for this to come along 😅

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!