Debug printing in Haskell

You can debug your haskell program with GHCI, but I think it's hard to use. I have used GDB or LLDB to debug in other language and GHCI debugging is somewhat similar, but it's harder to use.

A much more simpler way is to use trace for debug print.

First, import the Debug.Trace package:

import Debug.Trace

Then use trace at any point you want, there's no need to mess with the type signature of that function:

addArgumentToParam :: String -> String -> String
addArgumentToParam list word =
  trace ("word: " ++ word ++ " list: " ++ list) $
  list ++ "+" ++ word

Date: 2019-04-16 Tue 00:00

Author: Huy Tran

Created: 2019-05-17 Fri 11:52