• Stars
    star
    116
  • Rank 297,695 (Top 6 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mote

The programmer's assistant. Discharge your burdens with style.

Mote brings the development style found in Agda to Haskell, currently only as a vim plugin.

Requirements

Mote uses pathogen for the vim plugin and assumes you install pathogen bundles to ~/.vim/bundle.

Installation

Pick one of the following.

  1. If you trust me and are okay with programs being installed to /usr/local/bin, just do

    curl https://raw.githubusercontent.com/imeckler/mote/master/scripts/install.sh | bash

    Mote does not set any key bindings for the commands it provides, but a suggested set is given (commented out) here.

  2. If you don't or aren't, do what the script does:

  • First install cabalparse and make sure it's on your path.

  • Install mote via cabal install:

    git clone https://github.com/imeckler/mote.git
    cd mote
    cabal sandbox init
    cabal install mote -j
    mv .cabal-sandbox/bin/mote ~/.cabal/bin # or wherever
  • Install the vim plugin (which is in the vim directory of the repo)

  1. Personally, I would do this since it makes updating easy. First install cabalparse and then
mkdir ~/sandboxes # or wherever
cd sandboxes
git clone https://github.com/imeckler/mote.git
cd mote
cabal sandbox init
cabal install mote -j

and then symlink ~/sandboxes/mote/.cabal-sandbox/bin/mote to somewhere on your path. That way, updating is as easy as going to sandboxes/mote, doing a git pull followed by cabal install without having to reinstall dependencies.

Documentation

Mote provides the following vim commands.

  • MoteLoadCurrentFile

    (Re)loads the current file. By default, this is called on every file write. The first load takes a few seconds, but things should be snappy after that.

  • MoteToggleMode

    Toggles whether MoteLoadCurrentFile gets called on every write.

  • MoteNextHole

    Jumps the cursor to the next hole and displays bindings in scope in the hole as well as the goal type. I recommend binding this to option+k.

  • MotePrevHole

    Jumps the cursor to the previous hole and displays bindings in scope in the hole as well as the goal type. I recommend binding this to option+j.

  • Casex

    If x is a variable bound in a pattern match whose right hand side contains the current hole, :Casex x expands the pattern to case further on x. For example, if we have

    f :: [a] -> Int
    f xs = _

    then typing :Casex xs results in

    f :: [a] -> Int
    f []     = _
    f (x:xs) = _
  • CaseOn

    Fills the current hole by casing on some expression. For example, if we have

    f :: [a] -> Int
    f xs = _

    then typing :CaseOn xs results in

    f :: [a] -> Int
    f xs = case xs of
      []      -> _
      x : xs' -> _
  • MoteRefine

    Partially fill the current hole by providing a function that maps into the goal type. For example, if we have

    f :: [a] -> Int
    f xs = _

    then typing :MoteRefine length will result in

    f :: [a] -> Int
    f xs = length _

    I recommend binding this to option+r.

  • MoteStart

    Starts a Mote process running in the background. This is called automatically when a Haskell file is loaded and you should never need to call it.

Example session

When you don't know how to complete a program, you type a _ as a placeholder. For example, if we're writing a map function, we would put an underscore _ on the right hand side initially. We'll call our function map' so as not to clash with the Prelude function.

We then start the editing session by calling :MoteLoadCurrentFIle

An underscore expression is called a hole. When programming with Mote, there is a notion of the "current hole": the unfinished expression currently being worked on.

When you want to work on a particular hole, you enter the hole. The command in the Mote vim plugin is :call mote#nextHole(), which jumps your cursor to the next hole.

You'll notice that there is now an @ in the leftmost column, indicating the line of the current hole, and a new window has popped up displaying some information.

The information displayed is the "goal type", the type inferred for the current hole, and the names and types of local variables, which are likely to be useful for filling the hole. (In the future, this window will also display non-local values which are likely to be useful based on the hole type).

We now decide to pattern match on xs, and so we type :Casex xs, which expands a variable bound in a pattern and we jump to the next hole after filling it with _ : _.

Since our goal type is b, and we have a function f that returns a value of type b, we can refine the hole with f. by typing :MoteRefine f.

In general, if you are in a hole of type T, you can refine with an arbitrary expression of type A1 -> ... -> An -> T, which may itself contain holes.

We can then blow through the rest of the definition, alternatingly calling mote#nextHole() and MoteRefine to finally get

More Repositories

1

stationary

A static site generator library for OCaml
OCaml
17
star
2

proof

Haskell
8
star
3

diffgeo

JavaScript
8
star
4

ocamlfrp

FRP library in OCaml intended primarily for js_of_ocaml usage
OCaml
7
star
5

bba

Rust
7
star
6

curve-search

Rust
6
star
7

HackerNews-Scraper

A scraper and parser of data from HackerNews
Python
4
star
8

corejs

A partial "spiritual port" of Jane Street's Core to js_of_ocaml
OCaml
4
star
9

ratio

Ratio library for elm
Elm
3
star
10

virtual_dom

Virtual_dom bindings for js_of_ocaml
JavaScript
3
star
11

iterator

Pure iterators for elm
Elm
3
star
12

Command-Line-Calendar

Display information from your iCal calendar in the terminal
Objective-C
3
star
13

Idris-Elba

JavaScript
3
star
14

stage

"Pure signals" for making animations in elm
Elm
3
star
15

shortwords

Elm
3
star
16

Graph-Visualization

Includes a force driven visualizer for graphs, a module that builds a graph of a user's Facebook friends, and a module that builds a phylogenetic tree from a database
Python
2
star
17

cabalparse

A hack for slick
Haskell
2
star
18

piece

Elm
2
star
19

wordle-solver

Rust
2
star
20

compellingproof

A library for writing animated proofs
JavaScript
2
star
21

1d-automata

1 dimensional cellular automaton simulator
Haskell
2
star
22

tsuru_sample

Sample Haskell code for Tsuru
Haskell
2
star
23

intSched

Interactive scheduler 2.0
JavaScript
1
star
24

LiveScript-Meteor-Package

A Meteor package for the LiveScript language
JavaScript
1
star
25

haskomplete

Type based auto-complete for Haskell
Haskell
1
star
26

parachat

Peer to peer chat service
Haskell
1
star
27

etymonline-scrape

Haskell
1
star
28

CalParse

English language parsing for describing calendar events
Haskell
1
star
29

haskellgraph

A graph library in Haskell
Haskell
1
star
30

power2switch

Python
1
star
31

todo

A simple, useful todo list app
Haskell
1
star
32

either

An either type for elm
Elm
1
star
33

bfhaskell

A brainfuck interpreter in Haskell
Haskell
1
star
34

Watch

iPad app to monitor my computer remotely
C
1
star
35

algdraw

A small library for visualizing groups through their Cayley representations
Haskell
1
star
36

Command-Line-Plotter

Plots functions in ASCII. Mostly written as an exercise to help me learn Ruby.
Ruby
1
star
37

queue

Elm
1
star
38

oak

OCaml
1
star
39

Bill-Paying-Problem

Racket
1
star
40

elmasaki

HTML
1
star
41

turing

Turing machine drawings and related things
Haskell
1
star
42

befunge

A befunge interpreter in Haskell
Haskell
1
star
43

Command-Line-Lyrics

Python
1
star
44

Textish

1
star
45

Course-Evaluations-Scraper

This is a data-scraper for the UChicago course evaluations website. You must have a valid cNet ID to use this program.
1
star
46

funwithtypes

Some explorations of types. Type system implementation, theorem proving, etc
Haskell
1
star
47

wire

An implementation of the language described in the paper "The Two Dualities of Computation: Negative and Fractional Types"
Haskell
1
star
48

UChicago-Course-Watcher

Monitors the UChicago course registration website, sending you an email and/or a text message if a course you want becomes available.
Python
1
star