| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Flipper.Types
Description
- newtype ActorId = ActorId ByteString
- data Feature = Feature {}
- newtype Features = Features {}
- newtype FeatureName = FeatureName {}
- class HasActorId a where
- class Monad m => HasFeatureFlags m where
- class HasFeatureFlags m => ModifiesFeatureFlags m where
- newtype Percentage = Percentage Int
- update :: ModifiesFeatureFlags m => FeatureName -> (Maybe Feature -> Maybe Feature) -> m ()
- upsert :: ModifiesFeatureFlags m => Feature -> m ()
- isEnabledFor :: HasActorId a => Feature -> a -> Bool
- mkFeature :: FeatureName -> Feature
- mkFeatures :: Features
Documentation
A standardization of feature-enableable IDs.
Constructors
| ActorId ByteString |
A type describing an access-controlled feature.
Constructors
| Feature | |
Fields
| |
An abstraction representing the current state of the features store.
Constructors
| Features | |
Fields | |
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
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
Instances
| Monad m => HasFeatureFlags (FlipperT m) Source # | |
| (MonadIO m, HasFeatureFlags m) => HasFeatureFlags (StateT s m) Source # | |
| (MonadIO m, HasFeatureFlags m) => HasFeatureFlags (ReaderT * s m) Source # | |
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
Instances
| Monad m => ModifiesFeatureFlags (FlipperT m) Source # | |
| (MonadIO m, ModifiesFeatureFlags m) => ModifiesFeatureFlags (StateT s m) Source # | |
| (MonadIO m, ModifiesFeatureFlags m) => ModifiesFeatureFlags (ReaderT * s m) Source # | |
update :: ModifiesFeatureFlags m => FeatureName -> (Maybe Feature -> Maybe Feature) -> m () Source #
Updates a single Feature within the current monad
upsert :: ModifiesFeatureFlags m => Feature -> m () Source #
isEnabledFor :: HasActorId a => Feature -> a -> Bool Source #
mkFeature :: FeatureName -> Feature Source #
Smart constructor