Skip to content

Commit

Permalink
Fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ivnsch committed Nov 12, 2019
1 parent 78d8e56 commit 4140366
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import OrderQuantity
import OrderTakingDomain

someFunc :: IO ()
someFunc = putStrLn $ show $ KilogramQuantity 2.4
someFunc = print $ KilogramQuantity 2.4
11 changes: 6 additions & 5 deletions src/OrderTakingDomain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,27 @@ data Contact = Contact {

findOrderLine :: NonEmpty OrderLine -> OrderLineId -> Maybe OrderLine
findOrderLine orderLines olId =
L.find (\ol -> (orderLineId ol) == olId) orderLines
L.find (\ol -> orderLineId ol == olId) orderLines

replaceOrderLine :: NonEmpty OrderLine -> OrderLineId -> OrderLine -> NonEmpty OrderLine
-- TODO optimize
replaceOrderLine orderLines oldId newOrderLine =
map (\ol -> if ((orderLineId ol) == oldId) then newOrderLine else ol) orderLines
map (\ol -> if orderLineId ol == oldId then newOrderLine else ol) orderLines

changeOrderPrice :: Order -> OrderLineId -> Price -> Maybe Order
changeOrderPrice order orderLineId newPrice =
let
orderLine = findOrderLine (lines order) orderLineId

newOrderLine = (\ol -> ol { price = newPrice }) <$> orderLine
newOrderLines = (\nol -> replaceOrderLine (lines order) orderLineId nol) <$> newOrderLine
newOrderLines = replaceOrderLine (lines order) orderLineId <$> newOrderLine
in
(\nols -> order { lines = nols }) <$> newOrderLines

printQuantity qt =
case qt of
UnitQuantity q -> putStrLn $ show q
KilogramQuantity q -> putStrLn $ show q
UnitQuantity q -> print q
KilogramQuantity q -> print q

printList :: Show a => [a] -> String
printList list =
Expand Down

0 comments on commit 4140366

Please sign in to comment.