Type synonym using the TypeOf type family to specify HasState
constraints without having to specify the type associated to a tag.
Modulecapability-0.5.0.1Haskell2010
Capability.State
Defines a capability type class for a state effect. A state capability
provides a state which can be retrieved with get and set with put. As an
analogy, each state capability is equivalent to making one IORef available
in an IO computation (except, of course, that a state capability does not
have to be provided by IO).
This is a very expressive capability. It is often preferable to restrict to less powerful capabilities such as Capability.Reader, Capability.Writer, or Capability.Stream.
- 1 type
- Packagecapability-0.5.0.1
- Exports2
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceState.hs
Relational capability
0 declarationsFunctional capability
2 declarationsType family associating a tag to the corresponding type. It is intended to simplify constraint declarations, by removing the need to redundantly specify the type associated to a tag.
It is poly-kinded, which allows users to define their own kind of tags. Standard haskell types can also be used as tags by specifying the Type kind when defining the type family instance.
Defining TypeOf instances for GHC.TypeLits.Symbols (typelevel string
literals) is discouraged. Since symbols all belong to the same global
namespace, such instances could conflict with others defined in external
libraries. More generally, as for typeclasses, TypeOf instances should
always be defined in the same module as the tag type to prevent issues due to
orphan instances.
Example:
import Capability.Reader
data Foo
data Bar
type instance TypeOf Type Foo = Int
type instance TypeOf Type Bar = String
-- Same as: foo :: HasReader Foo Int M => …
foo :: HasReader' Foo m => …
foo = …
Strategies
0 declarationsModifiers
module Capability.Accessors