|
|
|
|
|
by sclv
3611 days ago
|
|
This is an interesting question. As much more of a Haskeller than an MLer I don't tend to feel the "need" to structure my programs explicitly modularly, and when I do I sort of instinctively use a combination of typeclasses and polymorphic higher-order functions to do so. More basically, just think "everywhere I would open a module, instead I can take a parameterized record of functions" (and furthermore, if a datatype uniquely determines that record, I can associate a typeclass to that datatype). There are limitations to this, but in fewer circumstances than you'd think -- mainly about sort of cross-modularity (aka the expression problem). There was a very nice discussion on lennart's blog about this in 2008, with a problem posed and some partial solutions (read bottom post to top): http://augustss.blogspot.com/2008_12_01_archive.html |
|
> We have basically packaged up the dictionary and unpack it ourselves to get access to the operations. It's not pleasant, but it works.
Would you say this method of using multi-parameter type classes and packaging/unpackaging related operations in a record is "idiomatic"? I admittedly haven't browsed all that much Haskell code, but I feel like I don't see it used that frequently.