Start using class instances instead of GADT constructors

Maybe makes more sense here?
This commit is contained in:
Niels G. W. Serup 2024-09-21 17:37:37 +02:00
parent 124d9fa4d8
commit 6a2a87cfc3
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
3 changed files with 9 additions and 4 deletions

View File

@ -75,8 +75,8 @@ genDependency g = do
inject :: Show a => a -> ComputationM ta a inject :: Show a => a -> ComputationM ta a
inject x = genDependency (Dependency NoToken (TInject x)) inject x = genDependency (Dependency NoToken (TInject x))
runIO :: (Show a, Show b) => FunctionIO a b -> Token t a -> ComputationM TokenNotTraversable b runIO :: (Show a, Show b, IsFIO f a b) => f -> Token t a -> ComputationM TokenNotTraversable b
runIO f input = genDependency (Dependency input (FIO f)) runIO f input = genDependency (Dependency input (FIO' f))
makeTraversable :: Token TokenNotTraversable [a] -> Token TokenTraversable (Token TokenNotTraversable a) makeTraversable :: Token TokenNotTraversable [a] -> Token TokenTraversable (Token TokenNotTraversable a)
makeTraversable (Token n) = Token n makeTraversable (Token n) = Token n

View File

@ -34,3 +34,8 @@ data ListDirectory' = ListDirectory'
deriving (Show) deriving (Show)
instance IsFIO ListDirectory' FilePath [FilePath] where instance IsFIO ListDirectory' FilePath [FilePath] where
runFIO ListDirectory' path = undefined runFIO ListDirectory' path = undefined
data OpenImage' = OpenImage'
deriving (Show)
instance IsFIO OpenImage' FilePath Image where
runFIO OpenImage' path = undefined

View File

@ -6,9 +6,9 @@ import ComputationM
test :: ComputationM TokenNotTraversable () test :: ComputationM TokenNotTraversable ()
test = do test = do
dir <- inject "retter" dir <- inject "retter"
dirContents <- runIO ListDirectory dir dirContents <- runIO ListDirectory' dir
let dirContents' = makeTraversable dirContents let dirContents' = makeTraversable dirContents
u <- mapM (runIO OpenImage) dirContents' u <- mapM (runIO OpenImage') dirContents'
pure $ NoToken pure $ NoToken
main :: IO () main :: IO ()