A minimum web dev DSL https://github.com/nfjinjing/miku

Latest on Hackage:2016.3.17

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Jinjing Wang
Maintained by Jinjing Wang


A tiny web dev DSL


{-# LANGUAGE OverloadedStrings #-}

import           Network.Miku
import           Network.Wai.Handler.Warp (run)

main :: IO ()
main = run 3000 . miku $ get "/" (text "miku power")


cabal update
cabal install miku
cabal install warp 

-- copy and paste the above example to myapp.hs

runghc myapp.hs

check: http://localhost:3000

Quick reference




{-# LANGUAGE OverloadedStrings #-}

import Network.Miku
import Network.Miku.Utils ((-))
import Network.Wai.Handler.Warp (run)
import Prelude hiding ((-))

main = run 3000 . miku - do

  get "/" - do
    -- something for a get request

  post "/" - do
    -- for a post request

  put "/" - do
    -- put ..

  delete "/" - do
    -- ..


get "/say/:user/:message" - do
  text . show =<< captures

-- /say/miku/hello will output
-- [("user","miku"),("message","hello")]

WAI integration

Use WAI middleware

import Network.Wai.Middleware.RequestLogger

middleware logStdout

Convert miku into a WAI application

-- in Network.Miku.Engine

miku :: MikuMonad -> Application


  • It's recommended to use your own html combinator / template engine. Try DIY with, e.g. moe.
  • Example view using custom html combinator (moe in this case)
  • When inspecting the request, use ask defined in ReaderT monad to get the Request, then use helper methods for wai to query it.
  • Response is in StateT, html and text are simply helper methods that update the state, i.e. setting the response body, content-type, etc.
  • You do need to understand monad transformers to reach the full power of miku.




  • Fix captures API to remain compatible with older versions
  • Remove lens dependenty to stay lean


  • Switch to WAI
  • Remove public and mime helpers, as those functionalities can be achieved through wai-middleware-static


  • Get rid of the Air dependency
  • Rewrite using common Haskell coding convention
comments powered byDisqus