feature-flags-0.1.0.1: A simple library for dynamically enabling and disabling functionality.

Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.FeatureFlag

Description

A small utility module that provides a foundation for dynamically enabling and disabling features.

Synopsis

Documentation

data FeatureToggle a Source

A simple toggle for selectively enabling or disabling functionality.

Constructors

Enabled 
Disabled 

data FeatureProvider a Source

A union of different feature providers which maintains a currently active provider and facilities for changing providers.

Use this when you don't need to disable a feature, just to replace the implementation.

enable :: FeatureToggle a -> FeatureToggle a Source

Enable a feature.

disable :: FeatureToggle a -> FeatureToggle a Source

Disable a feature.

toggle :: FeatureToggle a -> FeatureToggle a Source

Flip a toggle from enabled to disabled or vice versa.

withToggle :: FeatureToggle a -> b -> b -> b Source

Switch on values depending on whether a toggle is enabled or disabled.

whenEnabled :: (Functor m, Monad m) => FeatureToggle a -> m b -> m () Source

Execute an action only when the specified feature is enabled.

whenDisabled :: (Functor m, Monad m) => FeatureToggle a -> m b -> m () Source

Execute an action only when the specified feature is disabled.

use :: Text -> FeatureProvider a -> Either (FeatureProvider a) (FeatureProvider a) Source

Replace the current feature provider with another provider. Returns Left if the default provider is used due to a failed lookup. Returns Right if the lookup succeeded.

Use "default" as the lookup value if you want to explicitly load the default provider.

withProvider :: FeatureProvider a -> (a -> b) -> b Source

Apply a function that takes a feature provided by a FeatureProvider.