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
|
||||
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
|
||||
TInject :: b -> TypedRun () b
|
||||
InList :: ComputationM TokenNotTraversable b -> TypedRun [a] [b]
|
||||
|
@ -69,6 +69,12 @@ genDependency g = do
|
|||
inject :: Show a => a -> ComputationM ta a
|
||||
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 f input = genDependency (Dependency input (FIO f))
|
||||
|
||||
|
@ -78,7 +84,6 @@ convertImage = runIO ConvertImage
|
|||
saveFile = runIO SaveFile
|
||||
runPandoc = runIO RunPandoc
|
||||
|
||||
|
||||
makeTraversable :: Token TokenNotTraversable [a] -> Token TokenTraversable (Token TokenNotTraversable a)
|
||||
makeTraversable (Token n) = Token n
|
||||
|
||||
|
|
|
@ -5,11 +5,17 @@ module Functions where
|
|||
import Types
|
||||
import Sources
|
||||
|
||||
data Function a b where
|
||||
IsImageFilename :: Function FilePath Bool
|
||||
ConvertedImageFilename :: Function FilePath FilePath
|
||||
class (SourceState a, Show f) => IsF f a b | f -> a b where
|
||||
runF :: f -> a -> b
|
||||
|
||||
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
|
||||
runFIO :: f -> a -> IO b
|
||||
|
|
Loading…
Reference in New Issue