I just released version 0.10 of the dimensional library, adding an Enum
instance for quantities. Thus now it is possible to, e.g.:
> import Numeric.Units.Dimensional.Prelude
> import qualified Prelude
> xs = [1 *~ meter..] -- [1 m, 2 m, 3 m...]
However, I just realised that the behaviour may occasionally be surprising unless one keeps in mind that the default increment will be a product of SI base units and the value 1. For example:
> ys = [1 *~ kilo meter..] -- [1000 m, 1001 m, 1002 m...]
In order to avoid shooting oneself in the foot I recommended sticking with the enumFromThen
or enumFromThenTo
forms:
> zs = [1 *~ kilo meter, 2 *~ kilo meter..] -- [1000 m, 2000 m, 3000 m...]
Another option is to use *~~
(see my previous post):
> zs' = [1..] *~~ kilo meter -- [1000 m, 2000 m, 3000 m...]
In other news I’ve added a “search this blog” widget to the right to help myself find my pandoc article that I need to refer to every time I post. Feel free to use it!