From ad3bba2d1ae5da602b23e88ba38b3f7bb44ddf9d Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Tue, 24 Sep 2024 21:25:58 +0200 Subject: [PATCH] Remove unneeded type constraints --- byg/src/DependencyGenerator.hs | 21 ++++++++++----------- byg/src/Types/Dependency.hs | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index 6fa1daa..b71ea6f 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -26,7 +26,6 @@ import Types.Dependency (Action(..), Dependency, makeDependency) import Control.Monad.State (MonadState, State, runState, put, get) import Control.Monad.Writer (MonadWriter, WriterT, execWriterT, tell) -import Language.Haskell.TH.Syntax (Lift) newtype DepGenM' a = DepGenM { unDepGenM :: WriterT [Dependency] (State Int) a } deriving (Functor, Applicative, Monad, MonadState Int, MonadWriter [Dependency]) @@ -42,7 +41,7 @@ evalDepGenM m = fst (evalDepGenM' 0 m) tellDep :: Dependency -> DepGenM' () tellDep dep = tell [dep] -genDependencyM :: (Show a, Lift a) => (Token a -> DepGenM' Dependency) -> DepGenM a +genDependencyM :: (Token a -> DepGenM' Dependency) -> DepGenM a genDependencyM f = do top <- get let top' = top + 1 @@ -52,27 +51,27 @@ genDependencyM f = do tellDep result pure target -genDependency :: (Show a, Lift a) => (Token a -> Dependency) -> DepGenM a +genDependency :: (Token a -> Dependency) -> DepGenM a genDependency f = genDependencyM (pure . f) -inject :: (Show a, Lift a, Valuable a) => a -> DepGenM a +inject :: Valuable a => a -> DepGenM a inject x = genDependency (makeDependency NoToken (Inject (toValue x))) -getListElem :: (Show a, Lift a) => Token [a] -> DepGenM a +getListElem :: Token [a] -> DepGenM a getListElem outer = genDependency (makeDependency outer GetListElem) -setListElem :: (Show a, Lift a) => Token a -> Token [a] -> DepGenM () +setListElem :: Token a -> Token [a] -> DepGenM () setListElem a outer = do tellDep (makeDependency a SetListElem outer) pure NoToken -runFunction :: (Show a, Show b, Lift a, Lift b) => Function -> Token a -> DepGenM b +runFunction :: Function -> Token a -> DepGenM b runFunction f input = genDependency (makeDependency input (Function f)) -runFunctionIO :: (Show a, Show b, Lift a, Lift b) => FunctionIO -> Token a -> DepGenM b +runFunctionIO :: FunctionIO -> Token a -> DepGenM b runFunctionIO f input = genDependency (makeDependency input (FunctionIO f)) -mapDepGenM :: (Show a, Show b, Lift a, Lift b) => (Token a -> DepGenM b) -> Token [a] -> DepGenM [b] +mapDepGenM :: (Token a -> DepGenM b) -> Token [a] -> DepGenM [b] mapDepGenM f input = genDependencyM $ \target -> do top <- get let (res, top') = evalDepGenM' top $ do @@ -82,12 +81,12 @@ mapDepGenM f input = genDependencyM $ \target -> do put top' pure (makeDependency input (MapComp res) target) -mapDepGenM_ :: (Show a, Lift a) => (Token a -> DepGenM ()) -> Token [a] -> DepGenM () +mapDepGenM_ :: (Token a -> DepGenM ()) -> Token [a] -> DepGenM () mapDepGenM_ f input = do _ <- mapDepGenM f input pure NoToken -filterDepGenM :: (Show a, Lift a) => (Token a -> DepGenM Bool) -> Token [a] -> DepGenM [a] +filterDepGenM :: (Token a -> DepGenM Bool) -> Token [a] -> DepGenM [a] filterDepGenM f input = do conds <- mapDepGenM f input genDependency (makeDependency (TupleToken input conds) FilterComp) diff --git a/byg/src/Types/Dependency.hs b/byg/src/Types/Dependency.hs index 295a508..316971e 100644 --- a/byg/src/Types/Dependency.hs +++ b/byg/src/Types/Dependency.hs @@ -30,7 +30,7 @@ data UToken = UToken Int data Dependency = Dependency UToken Action UToken deriving (Show, Lift) -makeDependency :: (Show a, Show b, Lift a, Lift b) => Token a -> Action -> Token b -> Dependency +makeDependency :: Token a -> Action -> Token b -> Dependency makeDependency a action b = Dependency (makeUToken a) action (makeUToken b) makeUToken :: Token a -> UToken