Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: Pattern match(es) are overlapped when matching on strings

Tags:

haskell

I am trying to make a simple url route in Haskell and can't get around the warning:

Warning: Pattern match(es) are overlapped
             In a case alternative: "/" -> ...
Ok, modules loaded: Main.

the snippet:

{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.Wai.Handler.Warp (run)
import Network.Wai.Middleware.Debug (debug)
import Network.HTTP.Types (statusOK, status404)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import Data.ByteString.Char8 (unpack)
import Data.ByteString.Lazy.Char8 (pack)
import qualified Data.Text.Lazy as T
import Control.Monad.IO.Class (liftIO, MonadIO)

application req = do
  case unpack $ rawPathInfo req of
    "/items" -> itemsJSON 
    "/" -> indexPage
    _ ->  return $ responseLBS status404 [("Content-Type", "text/plain")]
          "Not found"

indexPage = do
  page <- liftIO $ L.readFile "templates/index.html"
  return $ responseLBS statusOK [("Content-Type", "text/html; charset=utf-8")] page

itemsJSON  =
  return $ responseLBS statusOK 
    [("Content-Type", "application/json; charset=utf-8")] "hi"

main =  do
  run 3000 $ debug $ application

UPD: replaced snippet with complete program, and

$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 6.12.1
like image 543
Dfr Avatar asked Jan 17 '26 20:01

Dfr


1 Answers

This is a bug, and is fixed in newer versions of GHC.

like image 178
Sjoerd Visscher Avatar answered Jan 21 '26 01:01

Sjoerd Visscher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!