开发者

Type definition for dimensions

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜