Remove mapM usage in monad
Was really a hack.
This commit is contained in:
parent
b4f36f9370
commit
f12ac12ea8
@ -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))
|
||||
|
||||
|
@ -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 ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user