about summary refs log blame commit diff
path: root/users/wpcarro/scratch/groceries/export.hs
blob: ed43c9a3e8870f36e8b43bcbc1916f698258291c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12

                 

                               







                                                                        


                                         





                                         
         
module Main where

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
  content <- readFile "./list.org"
  content
    |> lines
    |> filter (not . isUndesirableOutput)
    |> unlines
    |> putStrLn
  pure ()