Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orphan instances might be required on intermediate newtypes #5

Open
aherrmann opened this issue Aug 9, 2018 · 0 comments
Open

Orphan instances might be required on intermediate newtypes #5

aherrmann opened this issue Aug 9, 2018 · 0 comments

Comments

@aherrmann
Copy link
Member

E.g. in the following code

class Monad m => Logger m where
  logStr :: String -> m ()

newtype TheLoggerReader m a = TheLoggerReader (m a)
  deriving (Functor, Applicative, Monad)
instance  (HasReader "logger" (String -> IO ()) m, MonadIO m) => Logger (TheLoggerReader m)

newtype CountLogM m a = CountLogM (ReaderT CountLogCtx m a)
  deriving (Functor, Applicative, Monad)
  deriving Logger via
    (TheLoggerReader (Field "logger" (Field "logCtx" (MonadReader (ReaderT CountLogCtx m)))))

the deriving Logger via clause requires MonadIO instances for Field and MonadReader.
It might happen that a user is forced to define orphan instances for newtypes like MonadReader for type-classes that where not anticipated in this package. This may be unavoidable. However, we should make sure to systematically provide instances for a set of select common type-classes for all newtypes defined in this package.

See #4 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant