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

Safe HaskellNone



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



data FeatureToggle a Source

A simple toggle for selectively enabling or disabling functionality.



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.




enabledProvider :: a
enabledProviderName :: Text
availableProviders :: [(Text, a)]
defaultProvider :: a

enable :: FeatureToggle a -> FeatureToggle aSource

Enable a feature.

disable :: FeatureToggle a -> FeatureToggle aSource

Disable a feature.

toggle :: FeatureToggle a -> FeatureToggle aSource

Flip a toggle from enabled to disabled or vice versa.

withToggle :: FeatureToggle a -> b -> b -> bSource

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) -> bSource

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