GHC type output

Question. Is there any way to make this code without an explicit type signature?

the code. First, I have a class of more practical alternatives MonadTrans, inspired by Data.Newtype. It looks like this:

{-# LANGUAGE FlexibleContexts, TypeFamilies #-}

module Alt.Control.Monad.Trans where

import Control.Monad

class (Monad 𝔪, Monad (BaseMonad 𝔪)) => MonadTrans (𝔪 :: * -> *) where
    type BaseMonad 𝔪 :: * -> *
    lift :: (BaseMonad 𝔪) α -> 𝔪 α

Then I have a class Awith a method foo, and if some kind of base monad Mis A, then any converted monad is T Malso A. In code

class A 𝔪 where
    foo :: String -> 𝔪 ()

instance (A (BaseMonad 𝔪), MonadTrans 𝔪) => A 𝔪 where
    foo n = lift $ foo n

However, if now I want to create a shortcut for foowith the first argument replaced, I need an explicit type signature or an overflow of the compiler context stack.

minimize_call :: A 𝔪 => 𝔪 ()
minimize_call = foo "minimize"

, . , B :: * -> *. , , B B t /= t, B (B t) /= B t .., . . B - "" - newtype, newtype , A .

+5
1

, . A NoMonomorphismRestriction ( FlexibleInstances UndecidableInstances).

A .. , MonadTrans BaseMonad m = m. , , , .

{-# LANGUAGE FlexibleContexts, TypeFamilies, FlexibleInstances, UndecidableInstances, NoMonomorphismRestriction #-}

module Trans (MonadTrans(..), A(..), minimize_call) where

import Control.Monad

class (Monad m, Monad (BaseMonad m)) => MonadTrans (m :: * -> *) where
    type BaseMonad m :: * -> *
    lift :: (BaseMonad m) α -> m α

class A m where
    foo :: String -> m ()


data Foo a = Bork

instance Monad Foo where
    return _ = Bork
    _ >>= _ = Bork

instance A Foo where
    foo _ = Bork


instance (A (BaseMonad m), MonadTrans m) => A m where
    foo n = lift $ foo n

-- minimize_call :: A m => m ()
minimize_call = foo "minimize"

ghc 6.12, 7.0, 7.2 7.4. minimize_call , MR . , A m . MR . - , , . . , .

.

+3

All Articles