Rename 'MyMonad' to 'ReferenceM'

This commit is contained in:
Frederik Hanghøj Iversen 2019-11-14 15:57:13 +01:00
parent b28555b0f4
commit af1d0b9534

View file

@ -142,7 +142,7 @@ instance Semigroup Node where
(NodeDef{}, NodeModule{}) -> c1
(NodeDef (FQN n0 _), NodeDef (FQN n1 a1)) -> NodeDef $ FQN (n0 <> n1) a1
class Monad m => MyMonad (m :: Type -> Type) where
class Monad m => ReferenceM (m :: Type -> Type) where
declaration :: Node -> m ()
application :: Node -> m ()
getContext :: m Context
@ -163,7 +163,7 @@ instance ToJSON Result where
go :: (Node, Set Node) -> (Text, Aeson.Value)
go (x, y) = (prettyContext x, Aeson.toJSON y)
instance MyMonad (State Env) where
instance ReferenceM (State Env) where
declaration q = modify go
where
go :: Env -> Env
@ -192,7 +192,7 @@ instance MyMonad (State Env) where
where
go env = env { Rubyhs.References.context = q }
findClosest :: MyMonad m => Set Node -> Node -> m Node
findClosest :: ReferenceM m => Set Node -> Node -> m Node
findClosest decls n = do
Context c <- getContext
pure $ go $ c
@ -211,7 +211,7 @@ findClosest decls n = do
(NodeModule (Namespace [])) -> error "__IMPOSSIBLE__"
(NodeModule (Namespace xs)) -> NodeModule $ Namespace $ reverse $ Prelude.tail $ reverse xs
locally :: MyMonad m => m a -> m a
locally :: ReferenceM m => m a -> m a
locally act = do
old <- getContext
res <- act
@ -219,7 +219,7 @@ locally act = do
pure res
class References a where
entries :: MyMonad m => a -> m ()
entries :: ReferenceM m => a -> m ()
references :: Ruby.Begin -> Result
references q = Result $ HashMap.unionWith mappend applications declarations'
@ -229,7 +229,7 @@ references q = Result $ HashMap.unionWith mappend applications declarations'
declarations' = fromList $ (\x -> (x, mempty)) <$> toList declarations
instance References Ruby.Begin where
entries :: forall m . MyMonad m => Ruby.Begin -> m ()
entries :: forall m . ReferenceM m => Ruby.Begin -> m ()
entries (Ruby.Begin defs) = traverse_ (locally . entries) defs
instance References Ruby.Statement where
@ -293,7 +293,7 @@ instance References Ruby.Int where
instance References Ruby.Const where
entries con = application $ NodeModule $ constToNamespace con
updateContext :: MyMonad m => (Context -> Context) -> m ()
updateContext :: ReferenceM m => (Context -> Context) -> m ()
updateContext f = getContext >>= \c -> writeContext (f c)
instance References Ruby.Module where
@ -305,7 +305,7 @@ instance References Ruby.Module where
declaration $ NodeModule c
entries begin
atomToNode :: MyMonad m => Ruby.Atom -> m Node
atomToNode :: ReferenceM m => Ruby.Atom -> m Node
atomToNode (Ruby.Atom name) = do
namespace <- getContext >>= pure . \case
Context (NodeModule c) -> c