Skip to content

Instantly share code, notes, and snippets.

View sheganinans's full-sized avatar
💤
💤

Aistis Raulinaitis sheganinans

💤
💤
  • Data Scientist & Language Architect
  • Orange, CA
View GitHub Profile
@sheganinans
sheganinans / PM.py
Last active April 13, 2021 02:07
Python Pattern Matching in Python
"""
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.
@sheganinans
sheganinans / not_so_clp.m
Last active November 8, 2018 04:58
Not so Constraint Logic Programming with Mercury
:- module not_so_clp.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
@sheganinans
sheganinans / Main.hs
Created June 6, 2015 14:09
Yesod <> Clay
{-# 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)
@sheganinans
sheganinans / isoenv.nix
Created June 1, 2015 04:21
A mini isomorphic Haskell webdev environment
{ 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;