[Haskell-cafe] Problem with forall type in type declaration

Magicloud Magiclouds magicloud.magiclouds at gmail.com
Mon May 7 09:26:54 CEST 2012


Anyone could help on this?

On Fri, May 4, 2012 at 11:12 PM, Magicloud Magiclouds
<magicloud.magiclouds at gmail.com> wrote:
> Sorry to use Monad as the example, I meant this one:
>  run :: MonadTrans m => m IO a -> IO a
>
> And Daniel, I do not think adding another type "b" a good idea. Since
> "run" could actually return any inside type (depending on another
> function that passed to it). Even simple as different tuples would
> destroy this solution.
>
> On Fri, May 4, 2012 at 10:05 PM, Daniel Díaz Casanueva
> <dhelta.diaz at gmail.com> wrote:
>> If one parameter is not enough, you always can add more:
>>
>> Test m a b = Test { f :: m IO a -> IO b }
>>
>> This way, if
>>
>> run :: m IO a -> IO a
>>
>> then
>>
>> Test run :: Test m a a
>>
>> But for other type for your run function
>>
>> run' :: m IO a -> IO b
>>
>> you get
>>
>> Test run' :: Test m a b
>>
>> So you can have different types in input and output. Anyway, your type 'm'
>> is applied to other two types (m IO a), so it cannot be a monad, because
>> monads have arity 1 as type constructors, i.e. monads have kind (* -> *). Is
>> perhaps 'm' some kind of monad transformer?
>>
>> Well, that's all I can say from your explanation of the problem! Hope it
>> helps!
>>
>> Daniel Díaz.
>
>
>
> --
> 竹密岂妨流水过
> 山高哪阻野云飞
>
> And for G+, please use magiclouds#gmail.com.



-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.



More information about the Haskell-Cafe mailing list