2 ms·
Representing constraints in the type system is always an engineering tradeoff---how much type level machinery do you want to build vs the effort required to bui
by noelwelsh 11y ago
Representing constraints in the type system is always an engineering tradeoff---how much type level machinery do you want to build vs the effort required to build that?
Not sure what you mean by separating lines from rows. In the example you give of computing with units, I've seen examples of such systems in Scala (e.g. http://www.squants.com/ http://www.squants.com/) and F# comes with something built-in for this (IIUC). You might be interested in checking them out; it's quite neat.
- marcosdumay 11y ago> Not sure what you mean by separating lines from rows. It's the example Joe Spolsky used on the blog post about prefixes that everybody keeps pointing to. He showed code that worked on rows and columns (not lines, sorry) on a table, using prefixes to avoid mixing them. Haskell types do support this use, but you'll have to declare both types as Integral and Numeric, with the resulting boiterplate. I'm not sure exactly how to solve this, maybe a way to "lift" typeclasses out of a newtype declaration would be general enough. It is probably possible to do with template Haskell, but that is already outside of the language. That Scala library is interesting, although it looks like lots of the work is done at run time. Also, it looks like Haskell is able to do it [1]. (It's a recurring theme of mine, to complain that something can not be done on Haskell, just to discover somebody that did it.) [1] http://hackage.haskell.org/package/dimensional http://hackage.haskell.org/package/dimensional