Also, any decent Haskell IDEs out yet? I'm using emacs purely for the syntax highlighting. I tried leksah but I gave up trying to configure it properly on my box.
Also, any decent Haskell IDEs out yet? I'm using emacs purely for the syntax highlighting. I tried leksah but I gave up trying to configure it properly on my box.
lalala :: f g Int -> m q -> z ()
lalala = undefined
and then just check and see if your logic holds water. Then, slowly fill in the implementations and use -XImplicitParams and ?f or 7.8 type holes and _ as placeholders that GHC will tell you the goal types of.Reflect as much information about side effects into your types as possible. Write new typeclasses to encapsulate smaller APIs like
class Teletype m where
writeLine :: String -> m ()
readLine :: m String
instance Teletype IO where
writeLine = putStrLn
readLine = getLine
echo :: Teletype m => m r
echo = forever $ readLine >>= writeLine
Then now we know what subset of IO `echo` actually uses.Generally, the type system is your friend and used correctly it lets you write a shitty first draft of your program elegantly and quickly and then get to the hard part of typing it out later.
If foo is giving you problems, write it as
foo :: (the type you think it should have)
foo = undefined
If it compiles you at least know your type is right. Then, leaving the type annotation in place, replace undefined with a more useful expression. (Soon we will all be using Type Holes instead of this trick.)I like hdevtools for mark-errors-on-save. I don't know if there's an emacs hook for it, but it's emacs so probably.
If you're talking about debugging after it compiles... I'm still working on that. I spent part of this past weekend digging into QuickCheck.
What I get from that is my code is checked for style/compile errors everytime I save with ghc-mod and hlint. There's also commands to output the type of a function, run haskell code in VIM etc.
Note that you need ghc-mod installed for syntastic to take effect though.
[0] https://github.com/scrooloose/syntastic [1] https://github.com/dag/vim2hs
Additionally, Yesod relies heavily on quasiquoting and template haskell which can lead to some very cryptic code and errors. I generally prefer Snap for this reason and many others.
Eg. I had some problem where a Data.Text was being passed into a function where Data.Text.Lazy was expected (Network.Mail.Mime.simpleMail for the record). The error message was deep in the internals of Data.Text.Lazy rather than in my code. I had to play a ridiculous pecking game of using undefine on each time I use Data.Text in turn in order to find which particular Data.Text was causing the error and then explicitly force one particular argument type to be a Data.Text.Lazy. I didn't feel like the compiler helped me at all.
Stepping through a program linearly doesn't seem possible (though not entirely sure why not) so I have no intermediate or step through capability. I also can't (normally) just stick in a println in the middle of a function or view the data structures at any particular point of the program. These are two tools I use all the time with Java and C#, but in Haskell I am rendered blind.