disco-0.1.5: Functional programming language for teaching discrete math.
Copyrightdisco team and contributors
LicenseBSD-3-Clause
Maintainerbyorgey@gmail.com
Safe HaskellNone
LanguageHaskell2010

Disco.Effects.LFresh

Description

Polysemy effect for local fresh name generation, compatible with the unbound-generics library.

Synopsis

Documentation

data LFresh m a where Source #

Local fresh name generation effect.

Constructors

Lfresh :: Typeable a => Name a -> LFresh m (Name a) 
Avoid :: [AnyName] -> m a -> LFresh m a 
GetAvoids :: LFresh m (Set AnyName) 

getAvoids :: forall r. Member LFresh r => Sem r (Set AnyName) Source #

avoid :: forall r a. Member LFresh r => [AnyName] -> Sem r a -> Sem r a Source #

lfresh :: forall r a. (Member LFresh r, Typeable a) => Name a -> Sem r (Name a) Source #

runLFresh :: Sem (LFresh ': r) a -> Sem r a Source #

Dispatch an LFresh effect via a Reader effect to keep track of a set of in-scope names.

runLFresh' :: Sem (LFresh ': r) a -> Sem (Reader (Set AnyName) ': r) a Source #

lunbind :: (Member LFresh r, Alpha p, Alpha t) => Bind p t -> ((p, t) -> Sem r c) -> Sem r c Source #

Open a binder, automatically freshening the names of the bound variables, and providing the opened pattern and term to the provided continuation. The bound variables are also added to the set of in-scope variables within in the continuation.

absorbLFresh :: Member LFresh r => (LFresh (Sem r) => Sem r a) -> Sem r a Source #

data LFreshDict m Source #

Constructors

LFreshDict 

Fields

newtype Action m s' a Source #

Wrapper for a monadic action with phantom type parameter for reflection. Locally defined so that the instance we are going to build with reflection must be coherent, that is there cannot be orphans.

Constructors

Action (m a) 

Instances

Instances details
Monad m => Monad (Action m s') Source # 
Instance details

Defined in Disco.Effects.LFresh

Methods

(>>=) :: Action m s' a -> (a -> Action m s' b) -> Action m s' b #

(>>) :: Action m s' a -> Action m s' b -> Action m s' b #

return :: a -> Action m s' a #

Functor m => Functor (Action m s') Source # 
Instance details

Defined in Disco.Effects.LFresh

Methods

fmap :: (a -> b) -> Action m s' a -> Action m s' b #

(<$) :: a -> Action m s' b -> Action m s' a #

Applicative m => Applicative (Action m s') Source # 
Instance details

Defined in Disco.Effects.LFresh

Methods

pure :: a -> Action m s' a #

(<*>) :: Action m s' (a -> b) -> Action m s' a -> Action m s' b #

liftA2 :: (a -> b -> c) -> Action m s' a -> Action m s' b -> Action m s' c #

(*>) :: Action m s' a -> Action m s' b -> Action m s' b #

(<*) :: Action m s' a -> Action m s' b -> Action m s' a #

(Monad m, Reifies s' (LFreshDict m)) => LFresh (Action m s') Source # 
Instance details

Defined in Disco.Effects.LFresh

Methods

lfresh :: Typeable a => Name a -> Action m s' (Name a) #

avoid :: [AnyName] -> Action m s' a -> Action m s' a #

getAvoids :: Action m s' (Set AnyName) #