Skip to content

Instantly share code, notes, and snippets.

@kyagrd
kyagrd / FunctorRankNTypes.hs
Created February 22, 2013 02:09
DeriveFunctor works with RankNTypes in GHC
{-# LANGUAGE DeriveFunctor, RankNTypes, StandaloneDeriving #-}
-- The Glorious Glasgow Haskell Compilation System, version 7.4.1
data F x = C (([x] -> Bool) -> Maybe x) deriving Functor
data F1 x = C1 ((forall y . [(y,x)] -> y) -> Maybe x) deriving Functor
data F2 x = C2 (forall y . ([x] -> y) -> [(y,x)]) deriving Functor
@kyagrd
kyagrd / Mendler.agda
Created July 18, 2014 23:13
Mender-style in Agda (without positifity/termination checks)
{-# OPTIONS --no-positivity-check --no-termination-check #-}
module Mendler where
open import Data.Bool
-- open import Data.Product
-- open import Data.String
data μ (F : Set → Set) : Set where
In : F (μ F) → μ F
@kyagrd
kyagrd / HM+TCPoly+KindPoly
Last active March 30, 2018 10:49
HM+HigherKindedPoly+KindPoly in 25 lines of hacky Prolog
%%%% Hindley Milner + type constructor polymorphism + rank-1 kind poly
use_module(library(apply)).
use_module(librar(gensym)).
:- set_prolog_flag(occurs_check,true).
:- op(500,yfx,$).
kind(KC,var(Z),K1) :- first(Z:K,KC), instantiate(K,K1).
kind(KC,F $ G, K2) :- kind(KC,F,K1 -> K2), kind(KC,G,K1).
kind(KC,A -> B,o) :- kind(KC,A,o), kind(KC,B,o).

Getting started with PureScript 0.7.x

also posted on http://kyagrd.tumblr.com/post/125748583024/getting-started-with-purescript-0710 Written based on PureScript 0.7.1.0 but shoould work with versions 0.7.0.0 and 0.7.2.0.

Some Triva about PureScript

PureScript is a purely functional language specifically targeting JavaScript as its backend. If you have tasted Haskell and lamenting about the current untyped mess in scripting languages, especially regarding web-programming, probabiy your only choice out there is PureScript.

PureScript is the only language with a sane approch to staticaly support duck typing on records by using Row Polymorphism.

@kyagrd
kyagrd / CodeCogs.md
Last active August 29, 2015 14:26
CodeCogs online LaTeX snippet test

id

@kyagrd
kyagrd / MicroKanren.hs
Created December 13, 2015 12:31 — forked from msullivan/MicroKanren.hs
MicroKanren (μKanren) in Haskell
import Control.Monad
type Var = Integer
type Subst = [(Var, Term)]
type State = (Subst, Integer)
type Program = State -> KList State
data Term = Atom String | Pair Term Term | Var Var deriving Show
-- Apply a substitution to the top level of a term
// 콘솔 응용 프로그램 진입점 정의
#include "stdafx.h" // Visual C++에서 자동으로 생성해주는 녀석
int Main(void) // 이걸 메인함수라고 생각하고 프로그래밍하면 됨
{
printf("hello world");
return 0;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
font-size: calc(var(--font-size) * 1pt);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script id='template' style="text/template">
<p>아래에 생성된 폼은 다음 주소로 요청을 보냅니다.
<pre><%=url%></pre>
@kyagrd
kyagrd / pic.mod
Last active August 19, 2018 20:27
SIGPL2018Summer
module pic. %% file "pic.mod"
% eq X X.
% neq X Y :- eq X Y => fail.
one (inp X P) (dn X Y) (P Y).
one (out X Y P) (up X Y) P.
one (taup P) tau P.
one (par P Q) A (par P1 Q) :- one P A P1.
one (par P Q) A (par P Q1) :- one Q A Q1.