Difference between revisions of "Expanding type synonyms in error messages proposal"

From HaskellWiki
Jump to navigation Jump to search
(Created page with "There is a [https://mail.haskell.org/pipermail/ghc-devs/2015-June/009247.html thread started by Ömer Sinan Ağacan] in ghc-devs mailing list which suggests to add expansion o...")
 
(No difference)

Latest revision as of 09:14, 19 June 2015

There is a thread started by Ömer Sinan Ağacan in ghc-devs mailing list which suggests to add expansion of type-synonims in GHC's error-messages. Simon Peyton Jones suggested we should create a wiki-page for a collection of examples where you could see actual error-messages under discussion. This page is sort of that place. Feel free to add more examples.

Example: Pipes error

import           Control.Applicative
import           Pipes
import qualified Pipes.Prelude       as P
import           System.IO           (isEOF)

duplicate :: Monad m => a -> Producer a m ()
duplicate x = yield x >> yield x

loop :: Producer String IO ()
loop = for P.stdinLn duplicate

doubleUp :: Monad m => Consumer String m String
doubleUp = (++) <$> await <*> await

main :: IO ()
main = do
    runEffect $ loop >-> doubleUp

Current error message:

Couldn't match type ‘[Char]’ with ‘()’
Expected type: Proxy () String () X IO ()
  Actual type: Consumer String IO String
In the second argument of ‘(>->)’, namely ‘doubleUp’
In the second argument of ‘($)’, namely ‘loop >-> doubleUp’

Better error message:

Couldn't match type ‘[Char]’ with ‘()’
Expected type: Proxy () String () X IO ()
  Actual type: Consumer String IO String
Type-synonyms expanded:
     Expected: Proxy () [Char] () X IO ()
       Actual: Proxy () [Char] () X IO [Char]
In the second argument of ‘(>->)’, namely ‘doubleUp’
In the second argument of ‘($)’, namely ‘loop >-> doubleUp’