Skip to content

Instantly share code, notes, and snippets.

@rolph-recto
rolph-recto / HaskGo.hs
Created December 26, 2017 07:14
Go embedded in Haskell
{-# LANGUAGE DeriveFunctor #-}
import Control.Monad.State
import Control.Monad.Writer
import Control.Monad.Except
import Control.Monad.Free
import qualified Data.Map.Strict as M
data GoExpr =
GoInt Int
class Main inherits IO {
i : Int <- 1;
s : String;
main() : Object {{
while (i <= 16) loop {
out_string(line(i).concat(nline));
i <- i + 1;
} pool;
print_lines();
i <- 17;
@rolph-recto
rolph-recto / KmpIO.hs
Created August 6, 2015 04:34
seeded fault for kmpIO.hs in liquid haskell positive testcase
{-@ LIQUID "--no-termination" @-}
{-@ LIQUID "--short-names" @-}
{-@ LIQUID "--diff" @-}
module KMP (search) where
import Language.Haskell.Liquid.Prelude (liquidError)
import Data.IORef
import Control.Applicative ((<$>))
import qualified Data.Map as M
@rolph-recto
rolph-recto / gist:9593225
Last active August 29, 2015 13:57
document-system.ipynb
{
"metadata": {
"name": "Document System"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@rolph-recto
rolph-recto / chapter6.pl
Created December 21, 2013 01:28
Chapter 6 Exercises from Learn Prolog Now! by Blackburn and Bos
% chapter6.pl
append2([], L, L).
append2([X|T], L2, [X|L3]) :- append(T, L2, L3).
prefix(P, L) :- append2(P, _, L).
suffix(S, L) :- append2(_, S, L).
sublist(Sub, L) :- suffix(S, L), prefix(Sub, S).
@rolph-recto
rolph-recto / classify_manual.py
Created July 3, 2013 20:12
Script to classify tweets manually
# classify_politics.py
# manually classify tweets as political or not
import sys
import json
if __name__ == "__main__":
#read tweets from JSON file
@rolph-recto
rolph-recto / contractions.py
Last active January 14, 2016 18:06
Featureset builder for tweets Used for classification and other machine learning tasks
# contractions.py
# list from: http://en.wikipedia.org/wiki/Wikipedia:List_of_English_contractions
contractions = [
("aren't", "are not"),
("can't", "cannot"),
("can't've", "cannot have"),
("'cause", "because"),
("could've", "could have"),
("couldn't", "could not"),
("couldn't've", "could not have"),