Search code examples
haskellsyntaxlet

What is going on in this let expression?


I am reading through this blog post about writing an API in Haskell with Scotty, and I came across the section on monad transformers. I understand the concept of monad transformers, but I cannot wrap my head around what's going on here:

let r m = runReaderT (runConfigM m) c

How can the expression reference m when m is declared in the same let expression that uses it? What is going on here? What is m?


Solution

  • That's a (local) function declaration with the name r. m is the function's parameter. It's equivalent to:

    let r = \m -> runReaderT (runConfigM m) c