Ignore comments in output for grocery export
TL;DR: - Ignore lines starting with "#" - Tidy up the code
This commit is contained in:
parent
3b525e6d63
commit
0f160a8029
1 changed files with 14 additions and 3 deletions
|
@ -1,11 +1,22 @@
|
|||
module Main where
|
||||
|
||||
import Data.Function ((&))
|
||||
import qualified Data.List as L
|
||||
|
||||
(|>) :: a -> (a -> b) -> b
|
||||
x |> f = f x
|
||||
|
||||
-- | Ignore items with zero quantity (i.e. "0x") and comments (i.e. "#")
|
||||
isUndesirableOutput :: String -> Bool
|
||||
isUndesirableOutput x =
|
||||
(L.isPrefixOf "- 0x" x) || (L.isPrefixOf "#" x)
|
||||
|
||||
-- | Run this to export the grocery list.
|
||||
main :: IO ()
|
||||
main = do
|
||||
x <- readFile "./list.org"
|
||||
x & lines & filter (not . L.isPrefixOf "- 0x") & unlines & putStrLn
|
||||
content <- readFile "./list.org"
|
||||
content
|
||||
|> lines
|
||||
|> filter (not . isUndesirableOutput)
|
||||
|> unlines
|
||||
|> putStrLn
|
||||
pure ()
|
||||
|
|
Loading…
Reference in a new issue