Skip to content

Stack overflow instead of type check failure in Servant route

GHC 7.10.3 eats a lot of memory and segfaults compiling this.

{-# LANGUAGE DataKinds      #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE TypeOperators  #-}
module Main where

import           Data.Proxy

import           Servant.API -- requires servant

data A

apiP :: Proxy Api
apiP = Proxy

-- Users

type Api = "variants" :> Get '[JSON] ()

routeL :: URI
routeL = safeLink apiP
  (Proxy :: Proxy ("variants" :> Get '[A] ()))
                   -- Should result in type error
                   -- '[JSON] in route but '[A] here

main = print routeL

There is '[ JSON ] in Api type, but '[A] in Proxy type passed to safeLink, so it should result in type error.

Correct program compiles without problems.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information