-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#6 add volume module #9
Merged
Merged
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e22c518
Provide initial volume functions
katjam b0986d7
Add cubed and cbrt support to Quantity
katjam 4e12a92
Merge branch 'master' into 6-add-volume-module
katjam 41d3a1c
Remove unneccessary cm and mm function. Correct cbtr.
katjam 6e908c9
Merge branch '6-add-volume-module' of github.com:katjam/elm-units int…
katjam eed25b3
Tidier docs and remove deciliter stubs (no immediate need).
katjam 8edc9f4
Gallon conversions and correct Liter/Milliliter
katjam ccf08da
Volume fuzz tests and responsibility
katjam 89118f8
Convert to Quarts
katjam 1c8b749
Remove stray @doc added by elm-format
katjam 69c4b99
Add pints to Volume
katjam a041b4e
Add fluid ounces to Volume
katjam 348f813
Include conversion factors as helper constants
katjam a85a6aa
Tweak doc formatting
ianmackenzie 8a26370
Rename volume conversion constants
ianmackenzie d560643
Reword Volume doc comments
ianmackenzie 8d6c6ba
Merge remote-tracking branch 'upstream/master' into 6-add-volume-module
ianmackenzie 59b5d5c
Tweak documentation wording
ianmackenzie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,130 @@ | ||
module Volume exposing | ||
( Volume, CubicMeters | ||
, cubicMeters, inCubicMeters | ||
, cubicInches, inCubicInches, cubicFeet, inCubicFeet, cubicYards, inCubicYards | ||
, milliliters, inMilliliters, liters, inLiters | ||
--, usLiquidGallons, usDryGallons, imperialGallons | ||
--, usLiquidQuarts, usDryQuarts, imperialQuarts | ||
--, usLiquidPints, usDryPints, imperialPints | ||
--, usFluidOunces, imperialFluidOunces | ||
) | ||
|
||
{-| A `Volume` represents a volume in cubic meters, cubic feet, liters, | ||
US liquid gallons, imperial fluid ounces etc. It is stored as a number of cubic meters. | ||
|
||
@docs Volume, CubicMeters | ||
|
||
|
||
## Metric | ||
|
||
@docs cubicMeters, inCubicMeters | ||
@docs milliliters, inMilliliters, liters, inLiters | ||
|
||
|
||
## Imperial | ||
|
||
@docs cubicInches, inCubicInches, cubicFeet, inCubicFeet, cubicYards, inCubicYards | ||
--@docs usLiquidGallons, usDryGallons, imperialGallons | ||
--@docs usLiquidQuarts, usDryQuarts, imperialQuarts | ||
--@docs usLiquidPints, usDryPints, imperialPints | ||
--@docs usFluidOunces, imperialFluidOunces | ||
|
||
-} | ||
|
||
import Length exposing (Meters) | ||
import Quantity exposing (Quantity(..), Cubed) | ||
|
||
|
||
{-| -} | ||
type alias CubicMeters = | ||
Cubed Meters | ||
|
||
|
||
{-| -} | ||
type alias Volume = | ||
Quantity Float CubicMeters | ||
|
||
|
||
{-| Construct a volume from a number of cubic meters. | ||
-} | ||
cubicMeters : Float -> Volume | ||
cubicMeters numCubicMeters = | ||
Quantity numCubicMeters | ||
|
||
|
||
{-| Convert a volume to a number of cubic meters. | ||
-} | ||
inCubicMeters : Volume -> Float | ||
inCubicMeters (Quantity numCubicMeters) = | ||
numCubicMeters | ||
|
||
|
||
{-| Construct a volume from a number of cubic inches. | ||
-} | ||
cubicInches : Float -> Volume | ||
cubicInches numCubicInches = | ||
cubicMeters (0.0254 * 0.0254 * 0.0254 * numCubicInches) | ||
|
||
|
||
{-| Convert a volume to a number of cubic inches. | ||
-} | ||
inCubicInches : Volume -> Float | ||
inCubicInches volume = | ||
inCubicMeters volume / (0.0254 * 0.0254 * 0.0254) | ||
|
||
|
||
{-| Construct a volume from a number of cubic feet. | ||
-} | ||
cubicFeet : Float -> Volume | ||
cubicFeet numCubicFeet = | ||
cubicMeters (0.3048 * 0.3048 * 0.3048 * numCubicFeet) | ||
|
||
|
||
{-| Convert a volume to a number of cubic feet. | ||
-} | ||
inCubicFeet : Volume -> Float | ||
inCubicFeet volume = | ||
inCubicMeters volume / (0.3048 * 0.3048 * 0.3048) | ||
|
||
|
||
{-| Construct a volume from a number of cubic yards. | ||
-} | ||
cubicYards : Float -> Volume | ||
cubicYards numCubicYards = | ||
cubicMeters (0.9144 * 0.9144 * 0.9144 * numCubicYards) | ||
|
||
|
||
{-| Convert a volume to a number of cubic yards. | ||
-} | ||
inCubicYards : Volume -> Float | ||
inCubicYards volume = | ||
inCubicMeters volume / (0.9144 * 0.9144 * 0.9144) | ||
|
||
|
||
{-| Construct a volume from a number of milliliters. | ||
-} | ||
milliliters : Float -> Volume | ||
milliliters numMilliliters = | ||
cubicMeters (1.0e-6 * numMilliliters) | ||
|
||
|
||
{-| Convert a volume to a number of milliliters. | ||
-} | ||
inMilliliters : Volume -> Float | ||
inMilliliters volume = | ||
1.0e6 * inMilliliters volume | ||
|
||
|
||
{-| Construct a volume from a number of liters. | ||
-} | ||
liters : Float -> Volume | ||
liters numLiters = | ||
cubicMeters (1.0e-6 * numLiters) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has been corrected to 0.001 |
||
|
||
|
||
{-| Convert a volume to a number of liters. | ||
-} | ||
inLiters : Volume -> Float | ||
inLiters volume = | ||
1.0e6 * inLiters volume | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has been corrected to 1000 |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elm-format adds the extra
@docs
leader every time - have left these here for ref but will be sorted before it's ready to merge.