diff --git a/byg/src/DependencyRunner.hs b/byg/src/DependencyRunner.hs index 2e48a6f..832b08d 100644 --- a/byg/src/DependencyRunner.hs +++ b/byg/src/DependencyRunner.hs @@ -86,7 +86,7 @@ tupApp ta tb = App (App (typeRep @(,)) ta) tb listApp :: TypeRep a -> TypeRep [a] listApp ta = App (typeRep @[]) ta -runAction :: Action -> Value -> DepRunM Value +runAction :: Action a b -> Value -> DepRunM Value runAction action input = case action of Function f -> pure $ toValue $ evalFunction f $ fromValue input diff --git a/byg/src/Types/Dependency.hs b/byg/src/Types/Dependency.hs index 878107f..263a585 100644 --- a/byg/src/Types/Dependency.hs +++ b/byg/src/Types/Dependency.hs @@ -19,19 +19,19 @@ import Text.Printf (printf) import Data.Text (Text) import qualified Data.Text as T -data Action where - Function :: IsFunction f a b => f -> Action - InlineFunction :: Show b => TypeRep a -> TypeRep b -> F a b -> Action - FunctionIO :: IsFunctionIO f a b => f -> Action - Inject :: Value -> Action - FilterComp :: Show a => TypeRep a -> Action - UntupleFst :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action - UntupleSnd :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action - UnzipFst :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action - UnzipSnd :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action - MapComp :: (Typeable a, Show a, Typeable b, Show b) => TypeRep a -> TypeRep b -> [Dependency] -> Token a -> Token b -> Action +data Action a b where + Function :: IsFunction f a b => f -> Action a b + InlineFunction :: Show b => TypeRep a -> TypeRep b -> F a b -> Action a b + FunctionIO :: IsFunctionIO f a b => f -> Action a b + Inject :: Value -> Action () a + FilterComp :: Show a => TypeRep a -> Action ([a], [Bool]) [a] + UntupleFst :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action (a, b) a + UntupleSnd :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action (a, b) b + UnzipFst :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action [(a, b)] [a] + UnzipSnd :: (Show a, Show b) => TypeRep a -> TypeRep b -> Action [(a, b)] [b] + MapComp :: (Typeable a, Show a, Typeable b, Show b) => TypeRep a -> TypeRep b -> [Dependency] -> Token a -> Token b -> Action [a] [b] -deriving instance Show Action +deriving instance Show (Action a b) newtype F a b = F (a -> b) @@ -39,10 +39,10 @@ instance Show (F a b) where show = const "" data Dependency where - Dependency :: (Typeable a, Show a) => TypeRep a -> Token a -> Action -> TypeRep b -> Token b -> Dependency + Dependency :: (Typeable a, Show a) => TypeRep a -> Token a -> Action a b -> TypeRep b -> Token b -> Dependency deriving instance Show Dependency -makeDependency :: (Typeable a, Show a, Typeable b, Show b) => Token a -> Action -> Token b -> Dependency +makeDependency :: (Typeable a, Show a, Typeable b, Show b) => Token a -> Action a b -> Token b -> Dependency makeDependency a action b = Dependency typeRep a action typeRep b unListType :: Typeable a => TypeRep [a] -> TypeRep a @@ -51,7 +51,7 @@ unListType _ = typeRep unTupleType :: (Typeable a, Typeable b) => TypeRep (a, b) -> (TypeRep a, TypeRep b) unTupleType _ = (typeRep, typeRep) -actionTouchesFilesystem :: Action -> Bool +actionTouchesFilesystem :: Action a b -> Bool actionTouchesFilesystem = \case Function _ -> False InlineFunction _ _ _ -> False @@ -105,6 +105,7 @@ formatDependencyTrees = T.concat . (formatDependencyTrees' "") NoToken -> [ "--" ] + formatAction :: Text -> Action a b -> [Text] formatAction indentation = \case MapComp _ _ subDeps innerInput innerOutput -> concat [ [ "MapComp(" ]