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

Disco.Effects.Fresh

Description

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

Synopsis

Documentation

data Fresh m a where Source #

Fresh name generation effect, supporting raw generation of fresh names, and opening binders with automatic freshening. Simply increments a global counter every time fresh is called and makes a variable with that numeric suffix.

Constructors

Fresh :: Name x -> Fresh m (Name x) 

fresh :: forall r x. Member Fresh r => Name x -> Sem r (Name x) Source #

runFresh' :: Integer -> Sem (Fresh ': r) a -> Sem r a Source #

Dispatch the fresh name generation effect, starting at a given integer.

runFresh :: Sem (Fresh ': r) a -> Sem r a Source #

Run a computation requiring fresh name generation, beginning with 0 for the initial freshly generated name.

runFresh1 :: Sem (Fresh ': r) a -> Sem r a Source #

Run a computation requiring fresh name generation, beginning with 1 instead of 0 for the initial freshly generated name.

unbind :: (Member Fresh r, Alpha p, Alpha t) => Bind p t -> Sem r (p, t) Source #

Open a binder, automatically creating fresh names for the bound variables.

freshQ :: Member Fresh r => String -> Sem r (QName a) Source #

Generate a fresh (local, free) qualified name based on a given string.

absorbFresh :: Member Fresh r => (Fresh (Sem r) => Sem r a) -> Sem r a Source #

Run a Sem computation requiring a Fresh constraint (from the unbound-generics library) in terms of an available Fresh effect.

newtype FreshDict m Source #

Constructors

FreshDict 

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
Applicative m => Applicative (Action m s') Source # 
Instance details

Defined in Disco.Effects.Fresh

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 #

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

Defined in Disco.Effects.Fresh

Methods

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

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

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

Defined in Disco.Effects.Fresh

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 #

(Monad m, Reifies s' (FreshDict m)) => Fresh (Action m s') Source # 
Instance details

Defined in Disco.Effects.Fresh

Methods

fresh :: Name a -> Action m s' (Name a) #