From 61387f6eba8015ac11c9550418ab74817d677d47 Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Tue, 24 Sep 2024 21:14:27 +0200 Subject: [PATCH] Add skeletons for function implementations --- byg/src/Evaluation/Function.hs | 10 +++++++++- byg/src/Evaluation/FunctionIO.hs | 19 ++++++++++++++++++- byg/src/Types/Value.hs | 5 +++++ byg/src/Types/Values.hs | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/byg/src/Evaluation/Function.hs b/byg/src/Evaluation/Function.hs index 656a1b3..d7a6ba7 100644 --- a/byg/src/Evaluation/Function.hs +++ b/byg/src/Evaluation/Function.hs @@ -5,4 +5,12 @@ module Evaluation.Function import Types (Function(..), Value(..)) evalFunction :: Function -> Value -> Value -evalFunction = undefined +evalFunction f x = case (f, x) of + (IsImageFilename, String _) -> + Bool undefined + + (ConvertedImageFilename, String _) -> + String undefined + + _ -> + error "unexpected combination of function and argument type" diff --git a/byg/src/Evaluation/FunctionIO.hs b/byg/src/Evaluation/FunctionIO.hs index 8d39c9f..9957c86 100644 --- a/byg/src/Evaluation/FunctionIO.hs +++ b/byg/src/Evaluation/FunctionIO.hs @@ -5,4 +5,21 @@ module Evaluation.FunctionIO import Types (FunctionIO(..), Value(..)) evalFunctionIO :: FunctionIO -> Value -> IO Value -evalFunctionIO = undefined +evalFunctionIO f x = case (f, x) of + (ListDirectory, String _) -> + pure $ List undefined + + (ReadTemplate, String _) -> + pure $ Template undefined + + (ConvertImage, Tuple (Tuple (String _, String _), ImageConversionSettings _)) -> + pure $ Empty + + (SaveFile, Tuple (String _, String _)) -> + pure $ Empty + + (RunPandoc, String _) -> + pure $ String undefined + + _ -> + error "unexpected combination of function and argument type" diff --git a/byg/src/Types/Value.hs b/byg/src/Types/Value.hs index 95542d3..40ece10 100644 --- a/byg/src/Types/Value.hs +++ b/byg/src/Types/Value.hs @@ -8,7 +8,12 @@ import Types.Values import Language.Haskell.TH.Syntax (Lift) data Value = String String + | Bool Bool | ImageConversionSettings ImageConversionSettings + | Template Template + | Empty + | Tuple (Value, Value) + | List [Value] deriving (Show, Lift) class Valuable a where diff --git a/byg/src/Types/Values.hs b/byg/src/Types/Values.hs index 728b9e8..8db11ca 100644 --- a/byg/src/Types/Values.hs +++ b/byg/src/Types/Values.hs @@ -13,5 +13,5 @@ data TemplatePart = Literal String | KeyValue String deriving (Show, Lift) -data Template = Template [TemplatePart] +data Template = TemplateParts [TemplatePart] deriving (Show, Lift)