How would one define a type for dimensions?
Can you define a type in terms of another type? (i.e. an inch is 72 PostScript points).
Would it even make sense to make a new type for a d开发者_JAVA技巧imension unit?I've seen libraries for other kind of units, but the dimensions I'd be interested in are: scaled point (smallest, maybe Int?), point (65536 scaled points), pica (12 points), etc.
I think this is where phantom types can help. The dimensional package is a good place to start to understand them. The code is literate Haskell and very readable so I'd recommend reading through that.
精彩评论