Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Random snippets Skipping chapters 12-13 as it's mostly also random snippets and unclear if they're used in the repo.
- Loading branch information
Showing
4 changed files
with
39 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Lib (someFunc) where | ||
|
||
import OrderQuantity | ||
import OrderTakingDomain | ||
import qualified KilogramQuantity | ||
import Data.Aeson | ||
|
||
import UnvalidatedOrderLine | ||
|
||
someFunc :: IO () | ||
someFunc = print $ KilogramQuantity.create 2.4 | ||
someFunc = | ||
let | ||
str = "{\"orderLineId\" : \"1\", \"orderId\" : \"2\", \"productCode\" : \"3\",\"quantity\": 1}" | ||
uol = eitherDecode str :: Either String UnvalidatedOrderLine | ||
newstr = encode <$> uol | ||
in | ||
print newstr | ||
-- someFunc = print $ KilogramQuantity.create 2.4 | ||
|
||
|
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,8 @@ | ||
module OrderDto where | ||
|
||
import OrderLineDto | ||
|
||
data OrderDto = OrderDto { | ||
orderId :: String, | ||
orderLines :: [OrderLineDto] | ||
} deriving (Eq, Show) |
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,8 @@ | ||
module OrderLineDto where | ||
|
||
data OrderLineDto = OrderLineDto { | ||
orderLineId :: Int, | ||
productCode :: String, | ||
quantity :: Maybe Int, | ||
description :: String | ||
} deriving (Eq, Show) |
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,12 +1,19 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
|
||
module UnvalidatedOrderLine where | ||
|
||
import SharedTypes | ||
import qualified OrderId | ||
import qualified CustomerInfo | ||
import Data.Aeson | ||
import GHC.Generics | ||
|
||
data UnvalidatedOrderLine = UnvalidatedOrderLine { | ||
orderLineId :: String, | ||
orderId :: String, | ||
productCode :: String, | ||
quantity :: Double | ||
} | ||
} deriving (Show, Generic) | ||
|
||
instance FromJSON UnvalidatedOrderLine | ||
instance ToJSON UnvalidatedOrderLine |