Using a compiler specified on the command line or automatically detected Here is part of my build system. 

guessCompilers :: Options -&gt; IO Options
guessCompilers options =  foldl (&gt;&gt;=) (return options) modifiers where 
  modifiers = 
    [guessMetapost 
     -- guessAsymptote, 
     -- guessTex, 
     -- guessLatex, 
     -- guessXelatex
    ]   
guessMetapost :: Options -&gt; IO Options
guessMetapost opts = if isJust $ optMetaPost opts 
                         then 
                           putStrLn $ printf "using enforced Metapost compiler: %s" (fromJust $optMetaPost opts)
                           &gt;&gt; return opts
                         else do 
                           cc &lt;- compiler Metapost.interface
                           if isJust cc then putStrLn $ printf "found Metapost compiler: %s" (fromJust cc)
                                             else putStrLn "found Metapost compiler: none"


Compiler can be spectified by cmd args or can be guessed. But double checking for Nothing is not cool in my opinion. Also, I heard fromJust is evil. Any suggestions to improve my code?
Pattern match instead of using isJust and fromJust. (You could use maybe instead of pattern matching, but I think pattern matching is clearer in this case.)

This eliminates the possibility of forgetting to ensure a value is a Just before calling fromJust on it.

guessMetapost :: Options -&gt; IO ()
guessMetapost opts
   = case optMetaPost opts of
         Just mcc -&gt; putStrLn $ printf "using enforced Metapost compiler: %s" mcc
         Nothing -&gt; do
           cc' &lt;- compiler Metapost.interface
           case cc' of
               Just cc -&gt; putStrLn $ printf "found Metapost compiler: %s" cc
               Nothing -&gt; putStrLn "found Metapost compiler: none"


(Your code wasn't consistently returning any options, so I've stripped that bit out.)