{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE ImpredicativeTypes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE AllowAmbiguousTypes #-} module Conftrack.Source (ConfigSource(..), SomeSource(..)) where import Conftrack.Value (Key, Value(..), ConfigError(..)) import Control.Monad.State (StateT (..)) import Data.Text (Text) class ConfigSource s where type SourceState s fetchValue :: Key -> s -> StateT (SourceState s) IO (Either ConfigError (Value, Text)) leftovers :: s -> StateT (SourceState s) IO (Maybe [Key]) data SomeSource = forall source. ConfigSource source => SomeSource (source, SourceState source)