Debian Codegraph @

src/Lambdabot/Plugin/Novelty/Unlambda.hs

raw
1 -- Copyright (c) 2006 Don Stewart - http://www.cse.unsw.edu.au/~dons
2 -- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html)
3 --
4 -- | A plugin for the Haskell interpreter for the unlambda language
5 --
6 -- http://www.madore.org/~david/programs/unlambda/
7 module Lambdabot.Plugin.Novelty.Unlambda (unlambdaPlugin) where
8
9 import Lambdabot.Config.Novelty
10 import Lambdabot.Plugin
11 import Lambdabot.Util.Process
12 import Text.Regex.TDFA
13
14 unlambdaPlugin :: Module ()
15 unlambdaPlugin = newModule
16 { moduleCmds = return
17 [ (command "unlambda")
18 { help = say "unlambda <expr>. Evaluate an unlambda expression"
19 , process = \msg -> do
20 binary <- getConfig unlambdaBinary
21 ios80 (run binary msg scrub)
22 }
23 ]
24 }
25
26 scrub :: String -> String
27 scrub = unlines . take 6 . map (' ':) . lines . cleanit
28
29 cleanit :: String -> String
30 cleanit s | s =~ terminated = "Terminated\n"
31 | otherwise = s
32 where terminated = "waitForProc"