-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental support for units of measurement, only in constraint…
…s for now.
- Loading branch information
Showing
3 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{-# LANGUAGE DataKinds, StandaloneDeriving, TypeOperators #-} | ||
|
||
module Redfin.Language.Units (Year (..), Time, Power, Energy | ||
, module Data.Units.SI | ||
, module Data.Units.SI.Prefixes | ||
, module Data.Metrology.Poly ) where | ||
|
||
import Data.Metrology.Poly | ||
import Data.Metrology.SI () -- DefaultLCSU instances | ||
import qualified Data.Metrology.SI.PolyTypes as SI | ||
import Data.Units.SI | ||
import Data.Units.SI.Prefixes | ||
import Data.Metrology.Show | ||
import Data.Metrology.Unsafe | ||
import Redfin.Data.Fixed | ||
|
||
data Year = Year | ||
instance Unit Year where | ||
type BaseUnit Year = Second | ||
conversionRatio _ = 60 * 60 * 24 * 365.242 | ||
|
||
type Time = SI.Time 'DefaultLCSU Fixed | ||
|
||
type Power = SI.Power 'DefaultLCSU Fixed | ||
|
||
type Energy = Time %* Power | ||
|
||
t :: Time | ||
t = 30 % Year | ||
|
||
t' :: Fixed | ||
t' = ((1 % Watt :: Power) # milli Watt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
packages: | ||
- '.' | ||
resolver: lts-10.3 | ||
resolver: lts-10.3 | ||
extra-deps: | ||
- units-2.4.1 | ||
- units-defs-2.0.1.1 |