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 = Module ()
forall st. Module st
newModule
{ moduleCmds :: ModuleT () LB [Command (ModuleT () LB)]
moduleCmds = [Command (ModuleT () LB)]
-> ModuleT () LB [Command (ModuleT () LB)]
forall (m :: * -> *) a. Monad m => a -> m a
return
[ (String -> Command Identity
command String
"free")
{ help :: Cmd (ModuleT () LB) ()
help = String -> Cmd (ModuleT () LB) ()
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 <- (String -> Cmd (ModuleT () LB) String)
-> String -> Cmd (ModuleT () LB) String
forall (m :: * -> *).
MonadFail m =>
(String -> m String) -> String -> m String
freeTheoremStr (String -> String -> Cmd (ModuleT () LB) String
forall (m :: * -> *). MonadLB m => String -> String -> m String
query_ghci String
":t") String
xs
String -> Cmd (ModuleT () LB) ()
forall (m :: * -> *). Monad m => String -> Cmd m ()
say (String -> Cmd (ModuleT () LB) ())
-> (String -> String) -> String -> Cmd (ModuleT () LB) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unwords ([String] -> String) -> (String -> [String]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
lines (String -> Cmd (ModuleT () LB) ())
-> String -> Cmd (ModuleT () LB) ()
forall a b. (a -> b) -> a -> b
$ String
result
}
]
}