Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convenient constant arithmetic for Haskell's Dimensional package.
module Numeric.Units.Dimensional.ConstantArithmetic where
import qualified Prelude
import qualified Numeric.Units.Dimensional
import Numeric.Units.Dimensional.Prelude
a *. b = a * (b *~ one)
a .* b = (a *~ one) * b
a .*. b = (a *~ one) * (b *~ one)
a /. b = a / (b *~ one)
a ./ b = (a *~ one) / b
a ./. b = (a *~ one) / (b *~ one)
a +. b = a + (b *~ one)
a .+ b = (a *~ one) + b
a .+. b = (a *~ one) + (b *~ one)
a -. b = a - (b *~ one)
a .- b = (a *~ one) - b
a .-. b = (a *~ one) - (b *~ one)
squared a = a ^ pos2
cubed a = a ^ pos3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment