diff --git a/byg/byg.cabal b/byg/byg.cabal index 2436f7c..7bac461 100644 --- a/byg/byg.cabal +++ b/byg/byg.cabal @@ -17,6 +17,7 @@ library import: common hs-source-dirs: src exposed-modules: + Types Sources Functions ComputationM diff --git a/byg/src/ComputationM.hs b/byg/src/ComputationM.hs index b78ae23..c2deafc 100644 --- a/byg/src/ComputationM.hs +++ b/byg/src/ComputationM.hs @@ -1,17 +1,14 @@ {-# LANGUAGE GADTs #-} module ComputationM where +import Types +import Sources +import Functions + import Unsafe.Coerce (unsafeCoerce) import Control.Monad.State import Control.Monad.Writer -import Functions -import Sources - - -data ComputationRun a b = ComputationRun (Function a b) - | ComputationRunIO (FunctionIO a b) - data TypedRun a b where @@ -77,6 +74,9 @@ runIO f input = genDependency (Dependency input (FIO f)) listDirectory = runIO ListDirectory openImage = runIO OpenImage +convertImage = runIO ConvertImage +saveFile = runIO SaveFile +runPandoc = runIO RunPandoc makeTraversable :: Token TokenNotTraversable [a] -> Token TokenTraversable (Token TokenNotTraversable a) diff --git a/byg/src/Functions.hs b/byg/src/Functions.hs index 9814068..0ca37a8 100644 --- a/byg/src/Functions.hs +++ b/byg/src/Functions.hs @@ -2,37 +2,34 @@ {-# LANGUAGE FunctionalDependencies #-} module Functions where +import Types import Sources -data Image = Image - deriving (Show) -data ImageConversion = ImageConversion - deriving (Show) - data Function a b where IsImageFilename :: Function FilePath Bool ConvertedImageFilename :: Function FilePath FilePath deriving instance Show (Function a b) -data FunctionIO a b where - ConvertImage :: FunctionIO (Image, ImageConversion) Image - Save :: FunctionIO (a, FilePath) () - RunPandoc :: FunctionIO String String - -deriving instance Show (FunctionIO a b) - - - class (SourceState a, Show f) => IsFIO f a b | f -> a b where runFIO :: f -> a -> IO b -data ListDirectory = ListDirectory - deriving (Show) +data ListDirectory = ListDirectory deriving (Show) instance IsFIO ListDirectory FilePath [FilePath] where - runFIO ListDirectory path = undefined + runFIO ListDirectory _path = undefined -data OpenImage = OpenImage - deriving (Show) +data OpenImage = OpenImage deriving (Show) instance IsFIO OpenImage FilePath Image where - runFIO OpenImage path = undefined + runFIO OpenImage _path = undefined + +data ConvertImage = ConvertImage deriving (Show) +instance IsFIO ConvertImage Image Image where + runFIO ConvertImage _image = undefined + +data SaveFile = SaveFile deriving (Show) +instance IsFIO SaveFile (String, FilePath) () where + runFIO SaveFile _source = undefined + +data RunPandoc = RunPandoc deriving (Show) +instance IsFIO RunPandoc String String where + runFIO RunPandoc _source = undefined diff --git a/byg/src/Sources.hs b/byg/src/Sources.hs index 627586c..28a7fe8 100644 --- a/byg/src/Sources.hs +++ b/byg/src/Sources.hs @@ -1,5 +1,7 @@ module Sources where +import Types + import Data.ByteString (ByteString) data Source a where @@ -10,3 +12,9 @@ class SourceState a where instance SourceState FilePath where stateOfSource = undefined + +instance SourceState Image where + stateOfSource = undefined + +instance SourceState (String, FilePath) where + stateOfSource = undefined diff --git a/byg/src/Types.hs b/byg/src/Types.hs new file mode 100644 index 0000000..40ebc50 --- /dev/null +++ b/byg/src/Types.hs @@ -0,0 +1,4 @@ +module Types where + +data Image = Image + deriving (Show)