[Haskell-cafe] Unable to make a HList-like to deal with Kleisli Arrows and State

Gautier DI FOLCO gautier.difolco at gmail.com
Wed Jun 11 19:31:07 UTC 2014


Hi all,

My goal is to compose Kleisli arrows with (State s) as parameteric Monadic
type.
So, I end up with the following code:

data REnv :: [*] -> * -> * -> (* -> * -> *) -> ((* -> *) -> * -> * ->
*) -> * where
  Last  :: k (s t) i o -> REnv (t ': '[]) i o s k
  RCons :: k (s t) i o' -> REnv ts o' o s k -> REnv (t ': ts) i o s k


Which, of course, gives me the following error when I try to play with it:

*H> :t Last genRanking
<interactive>:1:6:
    Kind incompatibility when matching types:
      s :: * -> * -> *
      StateT Ranking :: (* -> *) -> * -> *
    Expected type: Kleisli (s t) Ticket Ranking
      Actual type: Kleisli (State Ranking) Ticket Ranking
    In the first argument of ‘Last’, namely ‘genRanking’
    In the expression: Last genRanking
<interactive>:1:6:
    Kind incompatibility when matching types:
      t :: *
      Data.Functor.Identity.Identity :: * -> *
    Expected type: Kleisli (s t) Ticket Ranking
      Actual type: Kleisli (State Ranking) Ticket Ranking
    In the first argument of ‘Last’, namely ‘genRanking’
    In the expression: Last genRanking*H> :t LastLast :: k (s t) i o
-> REnv '[t] i o s k*H> :t genRanking genRanking :: Kleisli (State
Ranking) Ticket Ranking


I understand why it fails (State is * -> * -> *, while s is * -> *),
but I can't figure out how to write this, I tried (s t o), but it
isn't correct because k waits for a (* -> *).

If you have any ideas, I'm curious to read them.

Thanks in advance for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140611/0c840e31/attachment.html>


More information about the Haskell-Cafe mailing list