[Haskell-cafe] Typeclasses -- if does not satisfy

Dmitry Bogatov KAction at gnu.org
Sat May 24 14:53:52 UTC 2014


Hello! I am working on package to generalize
common `runSomeThing` and `runSomethingT` functions.

It is very easy to generalize runStateT and runReaderT
like

        class Runnable a where
              type RunResult a
              run :: a -> RunResult a
        instance Runnable (StateT s m a) where
              --- Why ScopedTypeVariables do not work here?
              type RunResult (StateT s m a) = s -> m (a, s)
              run = runStateT
        --- ReaderT absolutely the same

But problem is that `State s a` is in fact `StateT s Identity a` and
I get type family conflicts.

In fact, it boils down to following:

   type family TestIdentity (m :: * -> *)
   type instance TestIdentity Identity = Int
   type instance TestIdentity m = () -- Anything but Identity.

In general, with all this TypeClass magic, I have a lot of ways that
something belong to some class, and no (aside OverlappingInstances)
to tell that it does NOT belong. I belive, there is reason to, but I do
not see it. Also, seems even TH does not helps here.

PS. Please, keep me in To:

--
Best regards, Dmitry Bogatov <KAction at gnu.org>,
Free Software supporter, esperantisto and netiquette guardian.
	git://kaction.name/rc-files.git
	GPG: 54B7F00D


More information about the Haskell-Cafe mailing list