1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Replace Control.Monad.Module with Syntax.Module.

This commit is contained in:
Rob Rix 2019-10-10 15:14:37 -04:00
parent cde9635319
commit 0f8fa337e4
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
6 changed files with 5 additions and 55 deletions

View File

@ -48,7 +48,6 @@ library
Analysis.Typecheck
Control.Carrier.Fail.WithLoc
Control.Effect.Readline
Control.Monad.Module
Core.Core
Core.Core.Parser
Core.Core.Pretty
@ -65,6 +64,7 @@ library
, directory ^>= 1.3
, filepath ^>= 1.4
, fused-effects ^>= 0.5
, fused-syntax
, haskeline ^>= 0.7.5
, parsers ^>= 0.12.10
, prettyprinter ^>= 1.2.1

View File

@ -16,7 +16,6 @@ import Control.Effect.Fresh as Fresh
import Control.Effect.Reader hiding (Local)
import Control.Effect.State
import Control.Monad ((>=>), unless)
import Control.Monad.Module
import Core.File
import Core.Loc
import Core.Name as Name
@ -38,6 +37,7 @@ import Data.Void
import GHC.Generics (Generic1)
import Prelude hiding (fail)
import Source.Span
import Syntax.Module
data Monotype f a
= Bool

View File

@ -1,50 +0,0 @@
{-# LANGUAGE FlexibleInstances, QuantifiedConstraints, MultiParamTypeClasses, TypeOperators #-}
module Control.Monad.Module
( RightModule(..)
, (>=>*)
, (<=<*)
, joinr
) where
import Control.Effect.Carrier
-- | Modules over monads allow lifting of a monads product (i.e. 'Control.Monad.join') into another structure composed with the monad. A right-module @f m@ over a monad @m@ therefore allows one to extend @m@s '>>=' operation to values of @f m@ using the '>>=*' operator.
--
-- In practical terms, this means that we can describe syntax which cannot itself bind or be substituted for variables, but which can be substituted inside when containing a substitutable expression monad. For example, we might not want to allow variables in a declaration context, but might still want to be able to substitute for e.g. globally-bound variables inside declarations; a 'RightModule' instance expresses this relationship nicely.
--
-- Note that we are calling this a right-module following Maciej Piróg, Nicolas Wu, & Jeremy Gibbons in _Modules Over Monads and their Algebras_; confusingly, other sources refer to this as a left-module.
--
-- Laws:
--
-- Right-identity:
--
-- @
-- m >>=* return = m
-- @
--
-- Associativity:
--
-- @
-- m >>=* (k >=> h) = (m >>=* k) >>=* h
-- @
class (forall g . Functor g => Functor (f g), HFunctor f) => RightModule f where
(>>=*) :: Monad m => f m a -> (a -> m b) -> f m b
infixl 1 >>=*
instance (RightModule f, RightModule g) => RightModule (f :+: g) where
L l >>=* f = L (l >>=* f)
R r >>=* f = R (r >>=* f)
(>=>*) :: (RightModule f, Monad m) => (a -> f m b) -> (b -> m c) -> (a -> f m c)
f >=>* g = \x -> f x >>=* g
infixl 1 >=>*
(<=<*) :: (RightModule f, Monad m) => (b -> m c) -> (a -> f m b) -> (a -> f m c)
g <=<* f = \x -> f x >>=* g
infixl 1 <=<*
joinr :: (RightModule f, Monad m) => f m (m a) -> f m a
joinr = (>>=* id)

View File

@ -37,7 +37,6 @@ module Core.Core
import Control.Applicative (Alternative (..))
import Control.Effect.Carrier
import Control.Monad.Module
import Core.Loc
import Core.Name
import Core.Scope
@ -51,6 +50,7 @@ import Data.Text (Text)
import GHC.Generics (Generic1)
import GHC.Stack
import Source.Span
import Syntax.Module
data Core f a
-- | Recursive local binding of a name in a scope; strict evaluation of the name in the body will diverge.

View File

@ -19,10 +19,10 @@ module Core.Scope
import Control.Applicative (liftA2)
import Control.Effect.Carrier
import Control.Monad ((>=>), guard)
import Control.Monad.Module
import Control.Monad.Trans.Class
import Core.Stack
import Data.Function (on)
import Syntax.Module
data Incr a b
= Z a

View File

@ -6,7 +6,7 @@ module Core.Term
import Control.Effect.Carrier
import Control.Monad (ap)
import Control.Monad.Module
import Syntax.Module
data Term sig a
= Var a