The miso CLI

Overview

miso is one binary that creates, builds, runs and serves miso applications. It has MicroHs (mhs) and MicroCabal (mcabal) built in, so there is no GHC to install: a project is a miso.yml, and its packages come from Hackage.

Install

On Linux and macOS (Intel and Apple Silicon), and on Windows in an MSYS2 shell:

$ curl -fsSL https://haskell-miso.org/download | sh
Copied

The installer downloads the release for your OS and architecture from haskell-miso/cli, checks its sha256, unpacks it in ~/.miso (or $MISO_HOME), and offers to add ~/.miso/bin to your PATH. It shows what it will do and asks first; sh -s -- --yes takes the defaults, and --no-modify-path leaves your shell's startup files alone. MISO_VERSION=v0.1.0 installs a given release.

With nix, the release is a flake package: nix profile install github:haskell-miso/cli#release.

Your first app

$ miso doctor
$ miso new counter
$ cd counter
$ miso dev
Copied

miso doctor checks the installation and the tools miso needs, and says how to fix what is missing. miso new makes a project from a template; miso dev builds it, serves public/ on http://localhost:8000, and rebuilds and reloads the page on every save.

Requirements

  • A C compiler (cc): mhs compiles programs to C.
  • For the browser targets (browser, browser_js), emscripten (emcc).
  • curl, tar, sha256sum or shasum, and git for git dependencies.
  • hlint, for miso lint only.

On Windows, install the tools in MSYS2 first: pacman -S gcc make tar curl git.

Every command

CommandWhat it does
miso new NAMEa new project from a template
miso templateslist the templates
miso initmake the current directory a project
miso build [NAME...]build the project, or the programs named
miso run [NAME] [ARGS]build a native program and run it
miso test [NAME...]build the tests and run them
miso dev [NAME]build, serve, and rebuild and reload on every change
miso serveserve public/ as it is
miso watch [NAME]type check on every change, and show the first error
miso lint [ARGS]run hlint on the sources
miso replMicroHs, interactively, with the project's modules
miso cleanremove what builds make
miso installinstall the dependencies of miso.yml
miso add PKG...add Hackage packages, and install them
miso remove PKG...remove dependencies
miso listthe installed packages
miso lockwrite miso.lock
miso updatelock again at the newest versions, and install
miso vendorcopy the locked sources to vendor/
miso cabalprint the .cabal file of the library
miso doctorcheck the installation and the tools
miso upgrade [VERSION]install the latest release, or VERSION
miso uninstallremove miso
miso versionthe versions of miso and MicroHs
miso helpthe commands
miso mhs ARGSthe MicroHs compiler built into the tool
miso mcabal ARGSMicroCabal, compiling with miso mhs

Conventions

  • Commands that work on a project read miso.yml in the current directory (not a parent), and fail without one. The others are new, templates, init, serve, repl, list and the commands of the tool itself.
  • ==> lines say what miso is doing or has done, -> lines are steps of it; warning: and error: go to standard error. NO_COLOR=1 turns colors off.
  • The exit status is 0 when the command worked and 1 when it failed. miso run and miso lint exit with the status of the program or of hlint; Ctrl-C exits with 130.
  • Commands that build install the dependencies first, when they are not installed yet.

Environment variables

Variable
MISO_HOMEwhere miso keeps downloads, git checkouts, the package list, the store and dev runtimes (default ~/.miso); the installer installs there too
NO_COLORset (non-empty) to turn off colors
MISO_INSTALL_URLwhere miso upgrade downloads the installer from
MISO_VERSIONfor the installer: the release to install (default the latest)
MISO_RELEASE_URLfor the installer: a mirror of the release files (or file://)
MISO_REPOfor the installer: the GitHub repository of the releases (default haskell-miso/cli)
MHSCPPHSthe cpphs mhs runs for modules with CPP (default the one next to miso)

Files and directories

In a project:

Path
miso.ymlthe project: see miso.yml
miso.lockthe locked dependencies; commit it
vendor/vendored sources (miso vendor); commit it
.miso/installed packages
dist/native programs and tests
public/browser programs, and their static files
.miso-build.logthe log of the last build

In $MISO_HOME (default ~/.miso):

Path
bin/miso, bin/cpphs, mhs-VERSION/the tool and its package database (when the installer installed it)
src/downloads and git checkouts
mcabal/MicroCabal's package list
store/built packages, shared by projects
rts/the browser runtimes of miso dev

In CI

The setup-miso GitHub Action installs a release and builds and tests a project with it:

- uses: haskell-miso/setup-miso@main
  with:
    version: latest