Personal tools

Lambdabot

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(Add smallCheck)
m (Added two more entries to the 'useful commands' list)
 
(12 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Lambdabot ==
+
[[Image:lambdabot.png|Lambdabot]]
   
 
Lambdabot is an IRC bot written over several years by those on the #haskell
 
Lambdabot is an IRC bot written over several years by those on the #haskell
[[IRC channel]]. It also operates in an offline mode as a Haskell development tool,
+
[[IRC channel]]. It also operates in an offline mode as a Haskell development tool, and embedded as an extension to ghci.
and embedded as an extension to ghci.
 
   
Lambdabot [http://www.cse.unsw.edu.au/~dons/lambdabot.html lives here].
+
Some useful commands for <code>#haskell</code>'s Lambdabot are
Lambdabot's source is available via a [http://darcs.net darcs]
+
* [[Haskell]] evaluation: <code>> take 5 [1..] ==> [1,2,3,4,5]</code>
repository, [http://www.cse.unsw.edu.au/~dons/lambdabot here]
+
* Defining persistent bindings for evaluation: <code>@let x = 4</code> sets <code>x</code> to 4. <code>@undef</code> deletes old definitions.
  +
* Asking for a functions type, like GHCi's <code>:t</code>, using either that or <code>@ty</code>, <code>@type</code>
  +
* Using Hoogle: <code>@hoogle [a] -> [a]</code>
  +
* [[Pointfree]] refactoring: <code>@pl \xs n -> take n xs ==> flip take</code>
  +
* Djinn takes a type signature and constructs a function satisfying it: <code>@djinn (a, b) -> c -> (b, c) ==> f (_, a) b = (a, b)</code>
  +
* What type does a monad transformer wrap? <code>@unmtl StateT s IO a ==> s -> IO (a, s)</code>
  +
* Convert do notation to bind notation: <code>@undo do { x <- getLine; print x } ==> getLine >>= \ x -> print x</code>
  +
* Lambdabot has a huge list of imports. If it can't find the name of a function you specified, try the fully qualified name. There is no way of importing modules manually.
   
Lambdabot is written in Haskell, and supports plugins for adding new
+
  +
=== Features ===
  +
  +
Lambdabot is written in Haskell ([http://darcs.net Darcs] repository [http://code.haskell.org/lambdabot here]), and supports plugins for adding new
 
commands. It has many plugins, including:
 
commands. It has many plugins, including:
   
Line 14: Line 14:
 
* [[Hoogle]] interface
 
* [[Hoogle]] interface
 
* [[Pointfree]] refactoring
 
* [[Pointfree]] refactoring
* A theorem prover, [[Libraries_and_tools/Theorem_provers|Djinn]].
+
* A theorem prover, [[Libraries and tools/Theorem_provers|Djinn]].
 
* Two [http://homepages.inf.ed.ac.uk/wadler/papers/free/free.ps free theorems] generators
 
* Two [http://homepages.inf.ed.ac.uk/wadler/papers/free/free.ps free theorems] generators
* A testing rig using [http://haskell.org/ghc/docs/latest/html/libraries/QuickCheck/Test-QuickCheck.html QuickCheck]
+
* A testing rig using [[QuickCheck]]
* Another test rig using SmallCheck
+
* Another test rig using [[SmallCheck]]
 
* A lambda calculus interpreter
 
* A lambda calculus interpreter
* A unlambda interpreter
+
* A Unlambda interpreter
* A bf interpreter
+
* A Brainfuck interpreter
 
* Haskell type and kind checking
 
* Haskell type and kind checking
 
* Dynamic plugin composition
 
* Dynamic plugin composition
 
* Haskell [http://darcs.haskell.org/packages/ library source] lookup
 
* Haskell [http://darcs.haskell.org/packages/ library source] lookup
 
* Language translation
 
* Language translation
* [http://www.cse.unsw.edu.au/~dons/code/lambdabot/State/quote Quotes]
+
* [http://code.haskell.org/lambdabot/State/quote Quotes]
 
* Todo lists
 
* Todo lists
 
* Irc functions
 
* Irc functions
* [http://darcs.net Darcs] patch tracking
+
* [[Darcs]] patch tracking
 
* A vixen/eliza personality
 
* A vixen/eliza personality
 
* Random dice
 
* Random dice
* [http://www.cse.unsw.edu.au/~dons/code/lambdabot/State/where Project database]
+
* [http://code.haskell.org/lambdabot/State/where Project database]
 
* Dictionary lookups
 
* Dictionary lookups
 
* Karma tracking
 
* Karma tracking
 
* User poll and election support
 
* User poll and election support
* Search google, wikipedia and more
+
* Search Google, Wikipedia and more
 
* Spell checking
 
* Spell checking
* [http://tinyurl.com Tiny url] generation
+
* [http://tinyurl.com Tiny URL] generation
 
* Much more...
 
* Much more...
  +
  +
=== Installing ===
  +
If you are using GHC 6.10.x, just <tt>[[cabal install]] lambdabot</tt>. 6.12.x support is forthcoming; see [[/Building]] for details on that. (It is possible that Hackage lambdabot will just work with 6.12.x.)
   
 
=== Interacting with the Bot ===
 
=== Interacting with the Bot ===
   
Almost all commands start with an <TT>@</TT>. A command is invoked by
+
Almost all commands start with an <TT>@</TT> or <tt>?</tt>. A command is invoked by
 
writing <TT>@<command-name> [args]</TT>. For example <TT>@type map</TT>
 
writing <TT>@<command-name> [args]</TT>. For example <TT>@type map</TT>
will make lambdabot respond with <TT>(a -> b) -> [a] -> [b]</TT>.
+
will make lambdabot respond with <hask>(a -> b) -> [a] -> [b]</hask>.
   
The special command <tt>@eval</tt> has a synonym <tt>></tt>, meaning that
+
The special command <tt>@run</tt> has a synonym <tt>></tt>, meaning that
 
you can evaluate Haskell expressions dynamically with:
 
you can evaluate Haskell expressions dynamically with:
  +
  +
<haskell>
 
> map (+1) [1..10]
 
> map (+1) [1..10]
 
[2,3,4,5,6,7,8,9,10,11]
 
[2,3,4,5,6,7,8,9,10,11]
  +
</haskell>
   
 
Good commands to know are <tt>@help</tt> and <tt>@list</tt>.
 
Good commands to know are <tt>@help</tt> and <tt>@list</tt>.
The full command list is [http://www.cse.unsw.edu.au/~dons/code/lambdabot/COMMANDS here].
+
The full command list is [http://code.haskell.org/lambdabot/COMMANDS here].
   
 
=== Contributing ===
 
=== Contributing ===
Line 63: Line 69:
 
For more info, see the sources or ask the bot itself. If you have any
 
For more info, see the sources or ask the bot itself. If you have any
 
questions about Lambdabot, ask on the #haskell irc channel.
 
questions about Lambdabot, ask on the #haskell irc channel.
  +
  +
=== How can it securely execute Haskell, on the Web? ===
  +
  +
See [[Safely running untrusted Haskell code]]
   
 
=== @version ===
 
=== @version ===
   
 
A list of various lambdabots over time.
 
A list of various lambdabots over time.
+
#haskell lambdabot 4p534, GHC 6.6 (Linux i686 2.66GHz)
#haskell lambdabot 4p172, GHC 6.5 (OpenBSD i386)
+
#haskell lambdabot 4p255, GHC 6.5 (OpenBSD i386)
#haskell lambdabot 3p396, GHC 6.4.1 (Linux i686 3.20GHz)
+
#haskell lambdabot 4p172, GHC 6.5 (OpenBSD i386)
  +
#haskell lambdabot 3p396, GHC 6.4.1 (Linux i686 3.20GHz)
  +
#haskell lambdabot 2p200, GHC 6.4 (OpenBSD i386)
  +
#haskell lambdabot ghc-6.2.2 (Mar 30 20:48:23 EST 2005) (OpenBSD i386)
 
#maya lambdabot 3.1p48, GHC 6.5 (OpenBSD i386)
 
#maya lambdabot 3.1p48, GHC 6.5 (OpenBSD i386)
#dutchhack (irc.cyberarmy.net) lambdabot 3p399, GHC 6.4.1 (Linux sparc64 )
+
#dutchhack (irc.cyberarmy.net) lambdabot 3p399, GHC 6.4.1 (Linux sparc64)
  +
  +
=== Lambdabot 2 ===
  +
  +
Sketch of design for a new lambdabot, smaller, more maintainable, more
  +
reliable. Features:
  +
  +
Core:
  +
* highly concurrent, as for lambdabot 1
  +
* multiple servers
  +
* configuration scripts
  +
* reliable, robust state checkpointing
  +
* command line, irc, and ide interface
  +
* simple plugin api
  +
* single cabalised bundle
  +
  +
New plugins:
  +
* beta reduction/term rewriting
  +
* hackage search
  +
* rss subscription
  +
  +
Improved plugins:
  +
* Hoogle
   
 
[[Category:Tools]]
 
[[Category:Tools]]

Latest revision as of 22:37, 16 February 2013

Lambdabot

Lambdabot is an IRC bot written over several years by those on the #haskell IRC channel. It also operates in an offline mode as a Haskell development tool, and embedded as an extension to ghci.

Some useful commands for #haskell's Lambdabot are

  • Haskell evaluation: > take 5 [1..] ==> [1,2,3,4,5]
  • Defining persistent bindings for evaluation: @let x = 4 sets x to 4. @undef deletes old definitions.
  • Asking for a functions type, like GHCi's :t, using either that or @ty, @type
  • Using Hoogle: @hoogle [a] -> [a]
  • Pointfree refactoring: @pl \xs n -> take n xs ==> flip take
  • Djinn takes a type signature and constructs a function satisfying it: @djinn (a, b) -> c -> (b, c) ==> f (_, a) b = (a, b)
  • What type does a monad transformer wrap? @unmtl StateT s IO a ==> s -> IO (a, s)
  • Convert do notation to bind notation: @undo do { x <- getLine; print x } ==> getLine >>= \ x -> print x
  • Lambdabot has a huge list of imports. If it can't find the name of a function you specified, try the fully qualified name. There is no way of importing modules manually.


Contents

[edit] 1 Features

Lambdabot is written in Haskell (Darcs repository here), and supports plugins for adding new commands. It has many plugins, including:

  • Haskell evaluation (with persistent declarations)
  • Hoogle interface
  • Pointfree refactoring
  • A theorem prover, Djinn.
  • Two free theorems generators
  • A testing rig using QuickCheck
  • Another test rig using SmallCheck
  • A lambda calculus interpreter
  • A Unlambda interpreter
  • A Brainfuck interpreter
  • Haskell type and kind checking
  • Dynamic plugin composition
  • Haskell library source lookup
  • Language translation
  • Quotes
  • Todo lists
  • Irc functions
  • Darcs patch tracking
  • A vixen/eliza personality
  • Random dice
  • Project database
  • Dictionary lookups
  • Karma tracking
  • User poll and election support
  • Search Google, Wikipedia and more
  • Spell checking
  • Tiny URL generation
  • Much more...

[edit] 2 Installing

If you are using GHC 6.10.x, just cabal install lambdabot. 6.12.x support is forthcoming; see /Building for details on that. (It is possible that Hackage lambdabot will just work with 6.12.x.)

[edit] 3 Interacting with the Bot

Almost all commands start with an @ or ?. A command is invoked by writing @<command-name> [args]. For example @type map

will make lambdabot respond with
(a -> b) -> [a] -> [b]
.

The special command @run has a synonym >, meaning that you can evaluate Haskell expressions dynamically with:

 > map (+1) [1..10]
 [2,3,4,5,6,7,8,9,10,11]

Good commands to know are @help and @list. The full command list is here.

[edit] 4 Contributing

Lambdabot is an open-source application. The @version command provides details on where to find the source. Anyone may write a plugin. To submit a plugin, use darcs send to submit it to the bot's current maintainer.

For more info, see the sources or ask the bot itself. If you have any questions about Lambdabot, ask on the #haskell irc channel.

[edit] 5 How can it securely execute Haskell, on the Web?

See Safely running untrusted Haskell code

[edit] 6 @version

A list of various lambdabots over time.

  #haskell                       lambdabot 4p534, GHC 6.6 (Linux i686 2.66GHz)
  #haskell                       lambdabot 4p255, GHC 6.5 (OpenBSD i386)
  #haskell                       lambdabot 4p172, GHC 6.5   (OpenBSD i386)
  #haskell                       lambdabot 3p396, GHC 6.4.1 (Linux i686 3.20GHz)
  #haskell                       lambdabot 2p200, GHC 6.4 (OpenBSD i386)
  #haskell                       lambdabot ghc-6.2.2 (Mar 30 20:48:23 EST 2005)  (OpenBSD i386)
  #maya                          lambdabot 3.1p48, GHC 6.5   (OpenBSD i386)
  #dutchhack (irc.cyberarmy.net) lambdabot 3p399, GHC 6.4.1 (Linux sparc64)

[edit] 7 Lambdabot 2

Sketch of design for a new lambdabot, smaller, more maintainable, more reliable. Features:

Core:

  • highly concurrent, as for lambdabot 1
  • multiple servers
  • configuration scripts
  • reliable, robust state checkpointing
  • command line, irc, and ide interface
  • simple plugin api
  • single cabalised bundle

New plugins:

  • beta reduction/term rewriting
  • hackage search
  • rss subscription

Improved plugins:

  • Hoogle