-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Runtime interpolation of environment variables in records using profunctors -- -- Runtime interpolation of environment variables in records using -- profunctors. See the README. @package interpolator @version 0.1.2 module Data.Interpolation -- | Newtype wrapper for an environment variable key. newtype TemplateKey TemplateKey :: Text -> TemplateKey [unTemplateKey] :: TemplateKey -> Text -- | Newtype wrapper for an environment variable value. newtype TemplateValue TemplateValue :: Text -> TemplateValue [unTemplateValue] :: TemplateValue -> Text -- | Type for a value that is described by -- '_env:ENVIRONMENT_VARIABLE:default' in JSON. data Template a Template :: TemplateKey -> Maybe a -> Template a [_templateKey] :: Template a -> TemplateKey [_templateDefault] :: Template a -> Maybe a -- | Type for a value that can be described either with '_env...' or as -- just a literal value in JSON. data Uninterpolated a Templated :: Template a -> Uninterpolated a Literal :: a -> Uninterpolated a data InterpolationFailure InterpolationFailureKeyNotFound :: TemplateKey -> InterpolationFailure InterpolationFailureValueNotReadable :: TemplateKey -> TemplateValue -> InterpolationFailure newtype InterpolationContext InterpolationContext :: Map TemplateKey TemplateValue -> InterpolationContext [unInterpolationContext] :: InterpolationContext -> Map TemplateKey TemplateValue -- | A class for parsing environment variable values, which should only be -- defined on primitives. Similar to Read except that for -- text-type values it should parse using identity. class FromTemplateValue a parseTemplateValue :: FromTemplateValue a => TemplateValue -> Maybe a -- | A class for showing environment variable values, which should only be -- defined on primitives. Similar to Show except that for -- text-type values it should use identity. class ToTemplateValue a toTemplateValue :: ToTemplateValue a => a -> TemplateValue newtype Interpolator templates identities Interpolator :: (templates -> Reader InterpolationContext (Validation [InterpolationFailure] identities)) -> Interpolator templates identities [runInterpolator] :: Interpolator templates identities -> templates -> Reader InterpolationContext (Validation [InterpolationFailure] identities) -- | Run a template using the interpolation context and failing if the -- value is not found or not readable. runTemplate :: FromTemplateValue a => Interpolator (Uninterpolated a) a mkInterpolationContext :: MonadIO m => m InterpolationContext interpolateWithContext :: (Default Interpolator templates identities, MonadIO m) => templates -> m (Either [InterpolationFailure] identities) interpolateWithContextExplicit :: MonadIO m => Interpolator templates identities -> templates -> m (Either [InterpolationFailure] identities) maybeGen :: Gen a -> Gen (Maybe a) noEnv :: Gen Text varNameAllowed :: Gen Text instance GHC.Classes.Ord Data.Interpolation.InterpolationFailure instance GHC.Classes.Eq Data.Interpolation.InterpolationFailure instance GHC.Show.Show a => GHC.Show.Show (Data.Interpolation.Uninterpolated a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Interpolation.Uninterpolated a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Interpolation.Uninterpolated a) instance GHC.Show.Show a => GHC.Show.Show (Data.Interpolation.Template a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Interpolation.Template a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Interpolation.Template a) instance Data.Aeson.Types.FromJSON.FromJSON Data.Interpolation.TemplateValue instance Data.Aeson.Types.ToJSON.ToJSON Data.Interpolation.TemplateValue instance GHC.Show.Show Data.Interpolation.TemplateValue instance GHC.Classes.Ord Data.Interpolation.TemplateValue instance GHC.Classes.Eq Data.Interpolation.TemplateValue instance Data.Aeson.Types.FromJSON.FromJSON Data.Interpolation.TemplateKey instance Data.Aeson.Types.ToJSON.ToJSON Data.Interpolation.TemplateKey instance GHC.Show.Show Data.Interpolation.TemplateKey instance GHC.Classes.Ord Data.Interpolation.TemplateKey instance GHC.Classes.Eq Data.Interpolation.TemplateKey instance GHC.Base.Functor (Data.Interpolation.Interpolator templates) instance GHC.Base.Applicative (Data.Interpolation.Interpolator templates) instance Data.Profunctor.Unsafe.Profunctor Data.Interpolation.Interpolator instance Data.Profunctor.Product.Class.ProductProfunctor Data.Interpolation.Interpolator instance Data.Profunctor.Product.Class.SumProfunctor Data.Interpolation.Interpolator instance Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator a a instance Data.Interpolation.FromTemplateValue a => Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator (Data.Interpolation.Uninterpolated a) a instance Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator a b => Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator (Data.Map.Internal.Map k a) (Data.Map.Internal.Map k b) instance (Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator a b, GHC.Classes.Ord a, GHC.Classes.Ord b) => Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator (Data.Set.Internal.Set a) (Data.Set.Internal.Set b) instance Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator a b => Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator [a] [b] instance Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator a b => Data.Profunctor.Product.Default.Class.Default Data.Interpolation.Interpolator (GHC.Maybe.Maybe a) (GHC.Maybe.Maybe b) instance Data.Interpolation.ToTemplateValue Data.Text.Internal.Text instance Data.Interpolation.ToTemplateValue GHC.Base.String instance Data.Interpolation.ToTemplateValue GHC.Types.Int instance Data.Interpolation.ToTemplateValue GHC.Types.Bool instance Data.Interpolation.ToTemplateValue a => Data.Aeson.Types.ToJSON.ToJSON (Data.Interpolation.Template a) instance (Data.Interpolation.ToTemplateValue a, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Types.ToJSON.ToJSON (Data.Interpolation.Uninterpolated a) instance Data.Interpolation.FromTemplateValue Data.Text.Internal.Text instance Data.Interpolation.FromTemplateValue GHC.Base.String instance Data.Interpolation.FromTemplateValue GHC.Types.Int instance Data.Interpolation.FromTemplateValue GHC.Types.Bool instance Data.Interpolation.FromTemplateValue a => Data.Aeson.Types.FromJSON.FromJSON (Data.Interpolation.Template a) instance (Data.Interpolation.FromTemplateValue a, Data.Aeson.Types.FromJSON.FromJSON a) => Data.Aeson.Types.FromJSON.FromJSON (Data.Interpolation.Uninterpolated a) instance GHC.Show.Show Data.Interpolation.InterpolationFailure instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Data.Interpolation.Uninterpolated a) instance Test.QuickCheck.Arbitrary.Arbitrary (Data.Interpolation.Uninterpolated Data.Text.Internal.Text) instance Test.QuickCheck.Arbitrary.Arbitrary Data.Interpolation.TemplateKey module Data.Interpolation.TH extractSumConstructorsAndNumFields :: Name -> Q [(Name, Int)] -- | Make an instance of Default for Interpolator of an ADT. -- Can't do it for an arbitrary Profunctor p because of partial -- functions. This splice is meant to be used in conjunction with -- makeAdaptorAndInstance for records as a way to project -- Default instances down to all leaves. -- --
-- data Foo' a b = Foo1 a | Foo2 b -- makeInterpolatorSumInstance 'Foo ---- --
-- instance (Default Interpolator a1 b1, Default Interpolator a2 b2) => Default Interpolator (Foo' a1 a2) (Foo' b1 b2) where -- def = Interpolator $ case -- Foo1 x -> Foo1 $ runInterpolator def x -- Foo2 x -> Foo2 $ runInterpolator def x --makeInterpolatorSumInstance :: Name -> Q [Dec]