Skip to content

Orphan instances might be required on intermediate newtypes #5

Open
@aherrmann

Description

@aherrmann

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions