Add nice wrappers

This commit is contained in:
Niels G. W. Serup 2024-09-21 17:41:04 +02:00
parent bb52c043cd
commit 5fc78b14ad
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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 ()