2020-06-27 15:06:59 +02:00
|
|
|
module Main where
|
|
|
|
|
|
|
|
import qualified Data.List as L
|
|
|
|
|
2020-10-03 12:00:11 +02:00
|
|
|
(|>) :: 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)
|
|
|
|
|
2020-06-27 15:06:59 +02:00
|
|
|
-- | Run this to export the grocery list.
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2020-10-03 12:00:11 +02:00
|
|
|
content <- readFile "./list.org"
|
|
|
|
content
|
|
|
|
|> lines
|
|
|
|
|> filter (not . isUndesirableOutput)
|
|
|
|
|> unlines
|
|
|
|
|> putStrLn
|
2020-06-27 15:06:59 +02:00
|
|
|
pure ()
|