jcpetruzza / barbies

BSD 3-Clause "New" or "Revised" License
92 stars 15 forks source link

More information about parameterised type constructors #4

Open buggymcbugfix opened 6 years ago

buggymcbugfix commented 6 years ago

This library looks super interesting. The README states that barbies are a common Haskell idiom.

What is the usual name for this and where can I find out more?

Also, where can I find example uses?

jcpetruzza commented 6 years ago

Hey, good questions!

What is the usual name for this and where can I find out more?

I don't know if they have a standard name. I used to refer to them as "types parametrized by a functor", but I find it too long. The parameterized-utils package defines analogs of the FunctorB / TraversableB classes (but without the automatic derivation of instances); and there they call them "structures that accept a single parametric type parameter", which is probably worse :smiley:

I'm sure the idea of putting a type-parameter f in front of your concrete types in a record goes back a long time. I seem to remember I first read someone mentioning it in the haskell-cafe mailing list many years ago, but I'm now unable to find it. It is a sort of folk-knowledge, I think, and I've seen data types defined in that way in the past in the wild, but unfortunately I don't know of any place to go read about it.

Also, where can I find example uses?

I gave a talk about the library at one one of the haskell meetups in London some time ago. The video is not up yet, I think, but the slides were for the most part code. Let me know if you need help reconstructing the context.

I'm using this mostly at work and I don't currently have other code examples in public repos, but these are some scenarios were I found it useful:

Hope this makes some sense!

buggymcbugfix commented 6 years ago

Thank you for this detailed reply! I think the context of the talk would be quite helpful, I presume I will have to pester Derek? If not, I will try to reconstruct, but what you have written here already makes a lot of sense and seems very sensible.

I will try to make use of Barbies in my code and see how I fare and what the caveats may be.

mstksg commented 5 years ago

@isovector explores these concepts pretty deeply in this blog post and calls them "higher-kinded data" :)