Skip to main content

Miking Workshop 2022: Install Miking

We currently support two methods of installing Miking:

  1. Natively installed binary using the Opam package manager. (Mac, Linux)
  2. Pre-built Docker images with optional dependencies included. (Windows, Mac, Linux)

For basic usage of Miking with a limited set of dependencies, we recommend the first option. If any of the extended Miking features are required, or if Opam is not suitable for your system, then we recommend installing one of the Docker images.

We also provide syntax highlighting for some of the popular editors. See the Install Syntax Highlighter section for more information.

Native Install with Opam (Mac, Linux)

For native install, opam is required and make is highly recommended.

Install Opam

See the Opam installation guide for how to install Opam on Mac or on your Linux distribution: Link

Create the Opam 4.14.0 switch named miking-workshop:

opam update
opam switch create miking-workshop 4.14.0
eval $(opam env)

Install required dependencies:

opam install dune linenoise sundialsml
info

You will not be able to complete the last part of Tutorial 2 without sundialsml. If you cannot install sundialsml on your system and still wish to complete the last part of Tutorial 2, we suggest using Docker instead.

Optional Dependencies

Many features in the standard library will not work without these additional dependencies. See the tab for your platform for more instructions.

Install the dependencies with Opam:

opam install pyml toml lwt owl ocamlformat.0.24.1

Opam should invoke your distribution's package manager if there are any additional dependencies needed.

Clone the Miking git repository to a suitable location on your system and enter the directory:

git clone https://github.com/miking-lang/miking.git
cd miking

If you do not have git installed on your system then you can manually download a zip file with the source code from our GitHub page: https://github.com/miking-lang/miking/archive/refs/heads/develop.zip

Assuming that you have downloaded the repository and are currently located in that directory, then you can either install Miking on your system with make or directly using your shell:

Install Miking

With make available, you can install Miking as:

make install

This will install the mi binary under $HOME/.local/bin, as well as the standard library under $HOME/.local/lib. If not already, make sure that $HOME/.local/bin is on your shell's PATH by running the following command directly or adding it to the appropriate .rc-file (e.g. .bashrc or .zshrc):

export PATH="$HOME/.local/bin:$PATH"

Install with Docker (Windows, Mac, Linux)

Before running the Docker image you must ensure that Docker is installed.

Install Docker on Your Platform
For Windows you will need to install the Docker Desktop application. See this page for more info. After installing it will most likely ask you to install Windows Subsystem for Linux (WSL) if you haven't already. This will require a restart of your computer.

With Docker Desktop installed and running, you should have access to the docker command from PowerShell.

Make sure that the Docker Desktop application is running. The docker command will not work otherwise.

Fetch the image by downloading it from Docker Hub:

docker pull mikinglang/workshop
caution

An executable built inside the Docker container should only be executed inside the Docker container.

Now you can run the Docker image as:

docker run --rm -it mikinglang/workshop bash

This will launch the miking Docker image with a bash shell where you have access to the mi command. The standard Docker image is based on Alpine and if additional features are desired within the Docker container such as an editor then they can be installed with the apk package manager.

All dependencies necessary for rebuilding the Miking compiler is also included in the Docker image should you wish to do any modifications. You will also find the Miking source code under /src/miking included in the image.

Example Launch Scripts

The entire Docker run command can be a bit cumbersome to type every time you want to compile something with Miking. We recommend wrapping the Docker run command in a script, for example:

Docker Helper scripts

Using GNU Make to launch the image with make run-docker:

Makefile
run-docker:
$(eval IMAGE := mikinglang/workshop:2022-1)
$(eval CONTAINERNAME := hello-miking)
$(eval PWD := $(shell pwd))
docker run --name $(CONTAINERNAME) \
--hostname $(CONTAINERNAME) \
--rm -it \
-v "$(PWD):/mnt:ro" \
$(IMAGE) bash

This will mount the directory where the Makefile is located under /mnt. If you also wish to write data to the same directory then this can be done by removing the :ro part.

If you need to run Docker with sudo, then either prepend the docker run in the Makefile rule with sudo or instead run sudo make docker-run.

Here is an example MExpr program that you can use to verify your installation. Save this as fib.mc and compile it with mi compile fib.mc. Try running it as ./fib 50.

fib.mc
/- These are from the Miking standard library -/
include "common.mc"
include "string.mc"

/- A string is a sequence of chars! -/
let s1: String = "foo"
let s2: [Char] = ['f', 'o', 'o']
utest s1 with s2

/- Fibonacci function -/
let fib = lam n.
recursive let work = lam i. lam curr. lam next.
if eqi i n then
curr
else
work (addi i 1) next (addi curr next)
in
work 0 0 1

mexpr

if neqi (length argv) 2 then
printLn (join ["usage: ", get argv 0, " N"]);
exit 1
else -- continue

let printFib = lam n.
printLn (join ["fib ", int2string n, " = ", int2string (fib n)])
in

loop (string2int (get argv 1)) printFib

Install Syntax Highlighter

Syntax highlighting is available for Miking in the editors Vim, Emacs, VSCode, and Sublime Text. See the corresponding tab below for information about how to install Miking syntax highlighting for your editor.

Choose your editor

See the miking-vim GitHub repository: Link