Also migrate Function
This commit is contained in:
parent
af50f16243
commit
b4f36f9370
|
@ -12,7 +12,7 @@ import Control.Monad.Writer
|
||||||
|
|
||||||
|
|
||||||
data TypedRun a b where
|
data TypedRun a b where
|
||||||
F :: Function a b -> TypedRun a b
|
F :: IsF f a b => f -> TypedRun a b
|
||||||
FIO :: IsFIO f a b => f -> TypedRun a b
|
FIO :: IsFIO f a b => f -> TypedRun a b
|
||||||
TInject :: b -> TypedRun () b
|
TInject :: b -> TypedRun () b
|
||||||
InList :: ComputationM TokenNotTraversable b -> TypedRun [a] [b]
|
InList :: ComputationM TokenNotTraversable b -> TypedRun [a] [b]
|
||||||
|
@ -69,6 +69,12 @@ 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))
|
||||||
|
|
||||||
|
run :: (Show a, Show b, IsF f a b) => f -> Token t a -> ComputationM TokenNotTraversable b
|
||||||
|
run f input = genDependency (Dependency input (F f))
|
||||||
|
|
||||||
|
isImageFilename = run IsImageFilename
|
||||||
|
convertedImageFilename = run ConvertedImageFilename
|
||||||
|
|
||||||
runIO :: (Show a, Show b, IsFIO f a b) => f -> 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))
|
||||||
|
|
||||||
|
@ -78,7 +84,6 @@ convertImage = runIO ConvertImage
|
||||||
saveFile = runIO SaveFile
|
saveFile = runIO SaveFile
|
||||||
runPandoc = runIO RunPandoc
|
runPandoc = runIO RunPandoc
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,17 @@ module Functions where
|
||||||
import Types
|
import Types
|
||||||
import Sources
|
import Sources
|
||||||
|
|
||||||
data Function a b where
|
class (SourceState a, Show f) => IsF f a b | f -> a b where
|
||||||
IsImageFilename :: Function FilePath Bool
|
runF :: f -> a -> b
|
||||||
ConvertedImageFilename :: Function FilePath FilePath
|
|
||||||
|
data IsImageFilename = IsImageFilename deriving (Show)
|
||||||
|
instance IsF IsImageFilename FilePath Bool where
|
||||||
|
runF IsImageFilename _path = undefined
|
||||||
|
|
||||||
|
data ConvertedImageFilename = ConvertedImageFilename deriving (Show)
|
||||||
|
instance IsF ConvertedImageFilename FilePath FilePath where
|
||||||
|
runF ConvertedImageFilename _path = undefined
|
||||||
|
|
||||||
deriving instance Show (Function a b)
|
|
||||||
|
|
||||||
class (SourceState a, Show f) => IsFIO f a b | f -> a b where
|
class (SourceState a, Show f) => IsFIO f a b | f -> a b where
|
||||||
runFIO :: f -> a -> IO b
|
runFIO :: f -> a -> IO b
|
||||||
|
|
Loading…
Reference in New Issue