diff options
author | Joris | 2021-05-29 19:24:41 +0200 |
---|---|---|
committer | Joris | 2021-05-29 19:24:41 +0200 |
commit | d48cafebb277e4ad4b31e883cbe4f55eef9ea4a4 (patch) | |
tree | 7f04fb49defa5fbc7984b0eee60bb7ce16a37ae2 /src/Order.purs | |
parent | 4e3cd92a8063a70dab9ae0ccafd0552c78c6e005 (diff) |
Rewrite in TypeScript
Diffstat (limited to 'src/Order.purs')
-rw-r--r-- | src/Order.purs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/Order.purs b/src/Order.purs deleted file mode 100644 index 33c2be9..0000000 --- a/src/Order.purs +++ /dev/null @@ -1,54 +0,0 @@ -module Order - ( Order - , OrderKind(..) - , OrderDirection(..) - , init - , select - ) where - -import Prelude (class Eq, (==)) -import Data.Generic (class Generic, gEq) - -type Order = - { kind :: OrderKind - , direction :: OrderDirection - } - -data OrderKind = - Name - | GlycemicIndex - | Carbohydrates - | GlycemicLoad - -derive instance genericOrderKind :: Generic OrderKind - -instance eqOrderKind :: Eq OrderKind where - eq = gEq - -data OrderDirection = - Ascending - | Descending - -derive instance genericOrderDirection :: Generic OrderDirection - -instance eqOrderDirection :: Eq OrderDirection where - eq = gEq - -init :: Order -init = - { kind: Name - , direction: initDirection - } - -select :: OrderKind -> Order -> Order -select kind order = - if order.kind == kind - then order { direction = otherDirection order.direction } - else order { kind = kind, direction = initDirection } - -otherDirection :: OrderDirection -> OrderDirection -otherDirection Ascending = Descending -otherDirection Descending = Ascending - -initDirection :: OrderDirection -initDirection = Ascending |