Dr Haskell
Dr Haskell is a tool to detect common mistakes in beginner Haskell programs. This program is still very much in development, and requires a working copy of Yhc to be available.
To get a feel for the power of Dr Haskell, see the following example, based on code sent to the haskell-cafe mailing list.
Given the file Test.hs:
module Test where
substitute1 :: Eq a => a -> [a] -> [a] -> [a]
substitute1 e l1 l2= [c | c <- check_elem l1]
where check_elem [] = l1
check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ check_elem xs
substitute2 e l l'
= concat (map subst_elem l)
where subst_elem x
| x == e = l'
| otherwise = [x]
subst3 e l [] = []
subst3 e l (x:xs) = if x == e then l ++ xs else x : subst3 e l xs
subst4 e l' = concat.map (\x->if x==e then l' else [x])
Produces the output:
> drhaskell Test.hs I can apply box_append in check_elem (5:10-6:80) I can apply concat_map in substitute2 (8:1-12:31) I can apply concat_map in subst4 (17:1-17:54)
A list of hints is provided, but more can be easily added, without even recompiling the program. The hints shown above correspond to concat . map can be replaced with concatMap, and [x] ++ xs can be replaced with x : xs. The hints are all available in the source file Hints.hs.
Installation
Step 1 is to get a working copy of Yhc.
Step 2 is to get a working copy of Dr Haskell, either from the darcs repo above (note, you'll need a source release of Yhc to compile Dr Haskell, since it requires some Yhc libraries), or download a Windows binary here, and extract all the files.
Use
Change into the same directory as the Dr Haskell program. First compile your sample code using Yhc, with the command yhc -corep File.hs, check that works, fix any errors. Next run drhaskell File.hs and see the results.
include("../elements/suffix.inc") ?>Downloads
- darcs get --partial http://www.cs.york.ac.uk/fp/darcs/drhaskell