From 5fc78b14ad53111cd77c82e3b66485b3cf4a3be7 Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Sat, 21 Sep 2024 17:41:04 +0200 Subject: [PATCH] Add nice wrappers --- byg/src/ComputationM.hs | 4 ++++ byg/src/Main.hs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/byg/src/ComputationM.hs b/byg/src/ComputationM.hs index 947e255..b78ae23 100644 --- a/byg/src/ComputationM.hs +++ b/byg/src/ComputationM.hs @@ -75,6 +75,10 @@ inject x = genDependency (Dependency NoToken (TInject x)) runIO :: (Show a, Show b, IsFIO f a b) => f -> Token t a -> ComputationM TokenNotTraversable b runIO f input = genDependency (Dependency input (FIO f)) +listDirectory = runIO ListDirectory +openImage = runIO OpenImage + + makeTraversable :: Token TokenNotTraversable [a] -> Token TokenTraversable (Token TokenNotTraversable a) makeTraversable (Token n) = Token n diff --git a/byg/src/Main.hs b/byg/src/Main.hs index 5c3d2c5..a69525b 100644 --- a/byg/src/Main.hs +++ b/byg/src/Main.hs @@ -6,9 +6,9 @@ import ComputationM test :: ComputationM TokenNotTraversable () test = do dir <- inject "retter" - dirContents <- runIO ListDirectory dir + dirContents <- listDirectory dir let dirContents' = makeTraversable dirContents - u <- mapM (runIO OpenImage) dirContents' + u <- mapM openImage dirContents' pure $ NoToken main :: IO ()