Remove mapM usage in monad

Was really a hack.
This commit is contained in:
Niels G. W. Serup 2024-09-21 18:45:39 +02:00
parent b4f36f9370
commit f12ac12ea8
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
2 changed files with 11 additions and 2 deletions

View File

@ -15,6 +15,7 @@ data TypedRun a b where
F :: IsF f a b => f -> TypedRun a b
FIO :: IsFIO f a b => f -> TypedRun a b
TInject :: b -> TypedRun () b
GetListElem :: TypedRun () b
InList :: ComputationM TokenNotTraversable b -> TypedRun [a] [b]
instance Show (ComputationM t a) where
@ -69,6 +70,9 @@ genDependency g = do
inject :: Show a => a -> ComputationM ta a
inject x = genDependency (Dependency NoToken (TInject x))
getListElem :: Show a => ComputationM ta a
getListElem = genDependency (Dependency NoToken GetListElem)
run :: (Show a, Show b, IsF f a b) => f -> Token t a -> ComputationM TokenNotTraversable b
run f input = genDependency (Dependency input (F f))

View File

@ -1,13 +1,18 @@
module Main where
import Types
import ComputationM
testSub :: ComputationM TokenNotTraversable Image
testSub = do
inp <- getListElem
openImage inp
test :: ComputationM TokenNotTraversable ()
test = do
dir <- inject "retter"
dirContents <- listDirectory dir
let dirContents' = makeTraversable dirContents
u <- mapM openImage dirContents'
u <- mapListTaken testSub dirContents
pure $ NoToken
main :: IO ()