Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is interesting, but several of the examples are useless (such as HList) or might not be a good idea in practice. Sometimes that's an easier way to explain a concept, but it would be helpful to see more examples that show you techniques that are actually recommended, rather than what not to do.


HLists actually aren't _useless_ in practice. I know I've used shapeless to do some datatype-generic programming with them (deriving CSV rows from a case class without reflection.)

Heterogenous unions are very similar and also extremely useful (multiple effects libraries build on top of them).


Well HList gives you something which behaves like a tuple with generic size. The difference between an HList and a type like (a * (b * (c * unit))) is that the HList can use the regular list syntax which is much nicer to match on (especially with type constructor disambiguation). Eg one could imagine a varadic list map function which behaves a bit like map in lisps (ie accepting any positive number of lists). Although this would need multiple types that look like lists because of the lack of higher kinded types in reason/ocaml


>several of the examples are useless (such as HList)

I tried to use a similar (though more streamlined) Vinyl [1] for implementing database querying that glued and sliced records to match the queries, but alas, GHC choked and died on the type-level list operations. That was several years ago though and I didn't touch Haskell since then, maybe something has changed.

[1] https://hackage.haskell.org/package/vinyl




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: