-- | Free theorems plugin
-- Andrew Bromage, 2006
module Lambdabot.Plugin.Haskell.Free (freePlugin) where

import Lambdabot.Plugin
import Lambdabot.Plugin.Haskell.Free.FreeTheorem
import Lambdabot.Plugin.Haskell.Type (query_ghci)

freePlugin :: Module ()
freePlugin :: Module ()
freePlugin = forall st. Module st
newModule
    { moduleCmds :: ModuleT () LB [Command (ModuleT () LB)]
moduleCmds = forall (m :: * -> *) a. Monad m => a -> m a
return
        [ (String -> Command Identity
command String
"free")
            { help :: Cmd (ModuleT () LB) ()
help = forall (m :: * -> *). Monad m => String -> Cmd m ()
say String
"free <ident>. Generate theorems for free"
            , process :: String -> Cmd (ModuleT () LB) ()
process = \String
xs -> do
                String
result <- forall (m :: * -> *).
MonadFail m =>
(String -> m String) -> String -> m String
freeTheoremStr (forall (m :: * -> *). MonadLB m => String -> String -> m String
query_ghci String
":t") String
xs
                forall (m :: * -> *). Monad m => String -> Cmd m ()
say forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unwords forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
lines forall a b. (a -> b) -> a -> b
$ String
result
            }
        ]
    }