Safe Haskell | None |
---|---|
Language | Haskell2010 |
- 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.
A type describing an access-controlled feature.
Feature | |
|
An abstraction representing the current state of the features store.
newtype FeatureName Source #
The main identifier of a feature
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) @
class Monad m => HasFeatureFlags m where Source #
The HasFeatureFlags
typeclass describes how to access the Features store
within the current monad.
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
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.
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
Monad m => ModifiesFeatureFlags (FlipperT m) Source # | |
(MonadIO m, ModifiesFeatureFlags m) => ModifiesFeatureFlags (StateT s m) Source # | |
(MonadIO m, ModifiesFeatureFlags m) => ModifiesFeatureFlags (ReaderT * s m) Source # | |
newtype Percentage 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