This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is an implementation of a simple (< 100LoC) *runtime* pattern matching system for Python. | |
`pm` is a function that takes two arguments, the object being matched over and some rule for that object. | |
If the pattern match fails, then `pm` returns `False`. | |
If the pattern match succeeds and there are no captured `Var`iables, then `pm` returns `True`. | |
Otherwise, `pm` will return a dict with the captured `Var`iables and their associated values. | |
This system will match and extract arbitrarily nested patterns on common Python data types. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- module not_so_clp. | |
:- interface. | |
:- import_module io. | |
:- pred main(io::di, io::uo) is det. | |
:- implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DoAndIfThenElse #-} | |
module Clay.Main where | |
import Control.Monad (mapM_) | |
import Data.Bool (Bool (..)) | |
import Data.Monoid ((<>)) | |
import Data.String (String) | |
import Data.Text.Lazy (Text) | |
import Data.Text.Lazy.IO (writeFile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {}, repo ? import <repo> {} }: # Make sure <repo> is defined in your | |
let # $NIX_PATH and pointing to a clone of: | |
# github.com/NixOS/nixpkgs | |
stdenv = pkgs.stdenv; | |
ghcp = repo.haskell-ng.packages; | |
ghc710 = ghcp.ghc7101; | |
ghcjs = ghcp.ghcjs; | |