feature-flipper-0.2.1.2: A minimally obtrusive feature flag library

Safe HaskellNone
LanguageHaskell2010

Control.Flipper.Types

Description

 

Synopsis

Documentation

newtype ActorId Source #

A standardization of feature-enableable IDs.

Constructors

ActorId ByteString 

data Feature Source #

A type describing an access-controlled feature.

Constructors

Feature 

Fields

newtype Features Source #

An abstraction representing the current state of the features store.

Constructors

Features 

class HasActorId a where Source #

Typeclass describing how to derive an ActorId from a datatype.

The resulting ActorId produced must be unique within the set of actors permitted to a given feature.

To clarify, let's say the actor is a User and User is defined as data User = User { id :: Int } It's sufficient to use the id alone if it is unique among Users and User types are the only actor type using a given Feature. However, if a Feature is used by both User types and `data Admin = Admin { id :: Int }` types where IDs are _not_ unique between types, it is recommended to avoid collisions by combining the type name and the ID unique to that type.

For example, the implementation for User and Admin could be @ instance HasActorId User where actorId user = User: <> show (user id)

instance HasActorId Admin where actorId user = Admin: <> show (user id) @

Minimal complete definition

actorId

Methods

actorId :: a -> ActorId Source #

class Monad m => HasFeatureFlags m where Source #

The HasFeatureFlags typeclass describes how to access the Features store within the current monad.

Methods

getFeatures :: m Features Source #

getFeatures access the Features store within the current monad

getFeatures :: (MonadTrans t, HasFeatureFlags m1, m ~ t m1) => m Features Source #

getFeatures access the Features store within the current monad

getFeature :: FeatureName -> m (Maybe Feature) Source #

getFeature access a single Feature within the current monad

getFeature :: (MonadTrans t, HasFeatureFlags m1, m ~ t m1) => FeatureName -> m (Maybe Feature) Source #

getFeature access a single Feature within the current monad

class HasFeatureFlags m => ModifiesFeatureFlags m where Source #

The ModifiesFeatureFlags typeclass describes how to modify the Features store within the current monad.

Methods

updateFeatures :: Features -> m () Source #

updateFeatures modifies the Features store within the current monad

updateFeatures :: (MonadTrans t, ModifiesFeatureFlags m1, m ~ t m1) => Features -> m () Source #

updateFeatures modifies the Features store within the current monad

updateFeature :: FeatureName -> Feature -> m () Source #

updateFeature modifies a single Feature within the current monad

updateFeature :: (MonadTrans t, ModifiesFeatureFlags m1, m ~ t m1) => FeatureName -> Feature -> m () Source #

updateFeature modifies a single Feature within the current monad

update :: ModifiesFeatureFlags m => FeatureName -> (Maybe Feature -> Maybe Feature) -> m () Source #

Updates a single Feature within the current monad

mkFeature :: FeatureName -> Feature Source #

Smart constructor