diff options
Diffstat (limited to 'scratch')
-rw-r--r-- | scratch/groceries/export.hs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/scratch/groceries/export.hs b/scratch/groceries/export.hs index c76033391d02..ed43c9a3e887 100644 --- a/scratch/groceries/export.hs +++ b/scratch/groceries/export.hs @@ -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 () |