Skip to content

Commit

Permalink
Version 0.1.0. Changed package to io.github.karols.units. Added some …
Browse files Browse the repository at this point in the history
…more documentation and methods. Bumped copyright year.
  • Loading branch information
KarolS committed Jan 2, 2014
1 parent 8cf8b18 commit fa09ec0
Show file tree
Hide file tree
Showing 98 changed files with 914 additions and 650 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
units - CHANGELOG
=================

version 0.1.0
-------------

* General: **Renamed the main package from `stasiak.karol.units` to `io.github.karols.units`.**

* General: added `power4`, `power5`, `inverseSquare`, `inverseCube`, `inversePower4` and `inversePower5` to `io.github.karols.units`

* General: Redesigned `WithU` and `WithA`.

version 0.0.9
-------------

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Karol M. Stasiak
Copyright (c) 2013-2014 Karol M. Stasiak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ units

Published under MIT License.

Current version: 0.0.9
Current version: 0.1.0
----------------------

[Changelog.](CHANGELOG.md)
Expand Down Expand Up @@ -41,16 +41,16 @@ Quick showcase
==============

``` scala
import stasiak.units._
import stasiak.units.defining._
import io.github.karols.units._
import io.github.karols.units.defining._

type USD = DefineUnit[_U~:_S~:_D]
type EUR = DefineUnit[_E~:_U~:_R]

implicit val EUR_to_USD = one[EUR].contains(1.25)[USD]

import stasiak.units.SI._
import stasiak.units.USCustomary._
import io.github.karols.units.SI._
import io.github.karols.units.USCustomary._

val priceInUSA = 200.of[USD/square[foot]]
val priceInGermany = 1500.of[EUR/square[metre]]
Expand Down Expand Up @@ -85,8 +85,8 @@ Defining units
You define a unit using `DefineUnit` type constructor with a type-level string as a parameter.

``` scala
import stasiak.units._
import stasiak.units.defining._
import io.github.karols.units._
import io.github.karols.units.defining._

type metre = DefineUnit[_m]
type second = DefineUnit[_s]
Expand Down Expand Up @@ -125,14 +125,16 @@ Note that this does not define a conversion from kilometres to centimetres. You
``` scala
implicit val km_to_cm = km_to_m >> m_to_cm
```
You can also quickly generate conversions for kg×m→kg×cm or m/s→cm/s:
You can also quickly generate conversions for kg×m→kg×cm, m/s→cm/s, J/m→J/cm, N/m²→N/cm²:

``` scala
implicit val kgm_to_kgcm = m_to_cm.times[kilogram]
implicit val mps_to_cmps = m_to_cm.dividedBy[second]
implicit val Jpm_to_Jpcm = m_to_cm.dividing[joule]
implicit val Npm2_to_Npcm2 = m_to_cm.pow2.dividing[newton]
```

See sources for `stasiak.units.SI` and `stasiak.units.USCustomary` objects for more examples.
See sources for `io.github.karols.units.SI` and `io.github.karols.units.USCustomary` objects for more examples.


Using values with units
Expand All @@ -141,7 +143,7 @@ Using values with units
All code below assumes the following is imported:

``` scala
import stasiak.units._
import io.github.karols.units._
```

You can create a value with a unit:
Expand Down Expand Up @@ -313,8 +315,8 @@ AffineSpace is defined as a pair containing a zero point and a unit.


``` scala
import stasiak.units._
import stasiak.units.defining._
import io.github.karols.units._
import io.github.karols.units.defining._

type celsius_deg = DefineUnit[_deg~:_C]
sealed trait CelsiusZero
Expand Down
2 changes: 1 addition & 1 deletion doc/ARRAYS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Using arrays
============

Sadly, Scala 2.10's arrays of value classes are boxed. As an alternative, `stasiak.units.arrays` package provides classes `DoubleUArray[U]`, `DoubleAArray[A]`, `IntUArray[U]`, and `IntAArray[A]`.
Sadly, Scala 2.10's arrays of value classes are boxed. As an alternative, `io.github.karols.units.arrays` package provides classes `DoubleUArray[U]`, `DoubleAArray[A]`, `IntUArray[U]`, and `IntAArray[A]`.

All of them implement `IndexedSeq` and can be used like standard collection classes:

Expand Down
16 changes: 8 additions & 8 deletions doc/BINDINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Artefact `units-scalaz` provides implementations of following typeclasses:

* for `Vector3A`: `Equal`, `Show`

Usage: `import stasiak.units.scalazSupport._`
Usage: `import io.github.karols.units.scalazSupport._`

Spire
-----

[Spire project page.](https://github.com/non/spire)

Currently, only Spire 0.3.x is supported.
Currently, only Spire 0.6.x is supported.

Artefact `units-spire` provides implementations of following typeclasses:

Expand All @@ -45,7 +45,7 @@ Artefact `units-spire` provides implementations of following typeclasses:

* for `Vector3U`: `VectorSpace[Vector3U[U], Double]`

Usage: `import stasiak.units.spireSupport._`
Usage: `import io.github.karols.units.spireSupport._`

Scalacheck
----------
Expand All @@ -56,7 +56,7 @@ Currently, only Scalacheck 1.10.x is supported.

Artefact `units-scalacheck` provides implementations of `Choose[IntU[U]]`, `Choose[DoubleU[U]]`, `Choose[IntA[A]]` and `Choose[DoubleA[A]]`.

Usage: `import stasiak.units.scalacheckSupport._`
Usage: `import io.github.karols.units.scalacheckSupport._`

Joda Time
---------
Expand All @@ -67,18 +67,18 @@ Currently, only Joda Time 2.1 and above is supported.

Artefact `units-joda` provides implicit conversions from and to `Duration`, `Seconds`, `Minutes`, and `Hours` classes.

Usage: `import stasiak.units.jodaSupport._`
Usage: `import io.github.karols.units.jodaSupport._`

Algebird
--------

[Algebird project page.](https://github.com/twitter/algebird)

Currently, only Algebird 0.1.13 is supported.
Currently, only Algebird 0.3.x is supported.

Artefact `units-algebird` provides implementations of `Monoid`, `Group` and `VectorSpace` for `IntU`, `DoubleU`, `Vector2U` and `Vector3U` (except for `VectorSpace` for `IntU`).

Usage: `import stasiak.units.algebirdSupport._`
Usage: `import io.github.karols.units.algebirdSupport._`

Slick
-----
Expand All @@ -89,4 +89,4 @@ Currently, only Slick 1.0.x is supported. Support for Slick 2.0 will follow afte

Artefact `units-slick` provides implementations of column mappings for `IntU`, `IntA`, `DoubleU` and `DoubleA`.

Usage: `import stasiak.units.slick1Support`
Usage: `import io.github.karols.units.slick1Support`
4 changes: 2 additions & 2 deletions doc/CUSTOM.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Custom types with units
Since 0.0.8, you can create add units to any type `N` you want. It will support arithmetic operations if there is an implementation of `Numeric[N]` and comparisons if there's `Ordering[N]`.

```scala
import stasiak.units._
import stasiak.units.SI._
import io.github.karols.units._
import io.github.karols.units.SI._

val x: WithU[BigInt, metre] = BigInt(100).of[metre]
val y: WithU[BigInt, metre] = BigInt(50).of[metre]
Expand Down
6 changes: 3 additions & 3 deletions doc/POLYMORPHISM.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ val workday = 8.of[hour]
MKS[T](workday.convert[second]) // explicit conversion required
```

A subset of generic units is defined in `stasiak.units.Mechanical`. By using it, the example above could be rewritten as:
A subset of generic units is defined in `io.github.karols.units.Mechanical`. By using it, the example above could be rewritten as:

``` scala
import stasiak.units.Mechanical._
import stasiak.units.SI._
import io.github.karols.units.Mechanical._
import io.github.karols.units.SI._

def position(x0: DoubleU[length], v0: DoubleU[speed], a: DoubleU[acceleration], t:DoubleU[time]) =
x0 + v0*t + a*t*t/2
Expand Down
35 changes: 18 additions & 17 deletions doc/TODO.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
TODO:
=====

For 0.1:
For 0.1.x (all 0.1.x are going to be backward-compatible up to 0.1.0):

* **move everything from `stasiak.karol.units` package to `stasiak.units`**
* add instances for `WithU` and `WithA`

* provide partial Scala 2.11 support

* rearrange `TChar`s, so that lexical sorting of unit names yields natural-looking compound units

* write more documentation
* fix found bugs

---

For 0.2 and beyond:
For 0.2:

* provide full Scala 2.11 support

* improve explicit polymorphism
* add [Pickling](https://github.com/scala/pickling) integration

* improve two-way affine space conversions

* figure out what to do with `WithU` and `WithA` and their incompatibility with typeclasses

* optimize compilation times

* test Proguard compatibility

* add [Pickling](https://github.com/scala/pickling) integration

* add `java.time` integration (JDK 8)

* add more units of measure

* write more tests

* write more benchmarks

* optionally: add [Breeze](https://github.com/dlwh/breeze), [Saddle](https://github.com/saddle/saddle), [Shapeless](https://github.com/milessabin/shapeless), [Slick 2](https://github.com/slick/slick) and [Squeryl](https://github.com/max-l/Squeryl) integration
* write more documentation

* optionally: rearrange `TChar`s, so that lexical sorting of unit names yields natural-looking compound units

* optionally: add runtime dynamic units

* optionally: make the library more IDE-friendly

* optionally: consider removing unnecessary features

* and finally: add more new features
---

For 0.3 and beyond:

* improve explicit polymorphism

* add `java.time` integration (JDK 8)

* optionally: add [Breeze](https://github.com/dlwh/breeze), [Saddle](https://github.com/saddle/saddle), [Shapeless](https://github.com/milessabin/shapeless), [Slick 2](https://github.com/slick/slick) and [Squeryl](https://github.com/max-l/Squeryl) integration

* and finally: add more new features
2 changes: 1 addition & 1 deletion doc/VECTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ All of the array classes implement `IndexedSeq` and can be used like standard co
They can be created in several ways:

``` scala
import stasiak.units.arrays._
import io.github.karols.units.arrays._

Vector2UArray.of[metre]((1,2), (4,5))

Expand Down
34 changes: 27 additions & 7 deletions generateSystem.scala.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#!/usr/bin/env python

# Copyright (c) 2013-2014 Karol M. Stasiak

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

F = None

def output(line):
Expand Down Expand Up @@ -96,7 +116,7 @@ def generate_system(size):
if(__name__=='__main__'):
F = open("units/src/main/scala/System.scala", "w")
output('''/*
Copyright (c) 2013 Karol M. Stasiak
Copyright (c) 2013-2014 Karol M. Stasiak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -120,13 +140,13 @@ def generate_system(size):
// This file is generated automatically, don't bother modifying.
// Modify generateSystem.scala.py instead.
package stasiak.karol.units
package io.github.karols.units
import stasiak.karol.units._
import stasiak.karol.units.internal.Integers._
import stasiak.karol.units.internal.Strings._
import stasiak.karol.units.internal.UnitImpl._
import stasiak.karol.units.internal.SingleUnits._
import io.github.karols.units._
import io.github.karols.units.internal.Integers._
import io.github.karols.units.internal.Strings._
import io.github.karols.units.internal.UnitImpl._
import io.github.karols.units.internal.SingleUnits._
''')

Expand Down
Loading

0 comments on commit fa09ec0

Please sign in to comment.