Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Companion module to Dep.Has for disambiguanting record components within an environment.
Similar in purpose to the Qualifier annotation in Java Spring.
>>>
:{
newtype Foo d = Foo {foo :: String -> d ()} deriving Generic makeIOFoo :: MonadIO m => Foo m makeIOFoo = Foo (liftIO . putStrLn) makeIOFoo' :: MonadIO m => Foo m makeIOFoo' = Foo (\_ -> liftIO $ putStrLn "this is secondary") env :: InductiveEnv '[Foo, Tagged "secondary" Foo] Identity IO env = AddDep @Foo (Identity makeIOFoo) $ AddDep @(Tagged "secondary" Foo) (Identity (tagged makeIOFoo')) $ EmptyEnv :}
>>>
:{
foo (dep env) "this is foo" :} this is foo
>>>
:{
foo (untag @"secondary" (dep env)) "this is foo" :} this is secondary
When using functions from Dep.SimpleAdvice (which tend to depend on coercions) with Tagged
components, remember to import the newtype's constructor.
Documentation
newtype Tagged s r_ m Source #
Very similar to the Data.Tagged
type from the "tagged" package, but
with an extra monad type argument. The intended use is to disambiguate
record components within an environment, when there are multiple records of the same
type.