Could not match kind type -> type with type in Hyper middleware

Hello all,

I’m triing to create custom hyper middleware, I checked typedef in hyper parseForm and it looks similar to mi typedef, but I get:

Could not match kind

    Type -> Type

  with kind

    Type


while checking the kind of Monad m => Request req m => Middleware m (Conn req res (Record c))
                                                         (Conn req res                       
                                                            { parsedUrl :: ParsedUrl         
                                                            | c                              
                                                            }                                
                                                         )                                   
in value declaration initRouter

in code

initRouter :: forall m req res c . 
  Monad m =>
  Request req m =>
  Middleware 
    m
    (Conn req res (Record c)) 
    (Conn req res { parsedUrl :: ParsedUrl | c })
initRouter = Ix.do
  requestData <- getRequestData
  modifyConn \conn -> conn { parsedUrl = (force requestData.parsedUrl) }

I also tried type, with same error

initRouter :: forall m req res c . 
  Monad m =>
  Request req m =>
  Middleware 
    m
    (Conn req res c) 
    (Conn req res c)

thank you in advance :slight_smile:

I’m not familiar with hyper middleware, but it seems like the compiler has inferred what it wants the type of initRouter to be, and your definition just doesn’t match that. Perhaps try commenting out the type definition, which will generate a compiler warning for not having a type definition on a top-level binding, and the warning will tell you what type signature it expects. That’ll probably get you the info you need on how to fix it.

1 Like

Thank you, that get me on track to solution :slight_smile: