Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
{-# LANGUAGE TemplateHaskell #-}
import Data.Lens.Template
import qualified Data.Map as Map
import Data.Map (Map)
import System.Random
import StatefulLens
@Heimdell
Heimdell / .gitignore
Last active August 29, 2015 13:56
SDL bindings
*.out
*.a
#pragma once
#include <cmath>
#include <iostream>
using namespace std;
static constexpr int pow(int x, int n) {
@Heimdell
Heimdell / Behaviour.hs
Last active August 29, 2015 13:57
How to understand X? Make it yourself. So, this is my understanding of Functional Reactive Programming (powered by arrows).
module Behaviour where
import Prelude hiding (id, (.), head, tail, zip, unzip, map, repeat, cycle)
import Control.Applicative
import Control.Arrow
import Control.Category
import Data.Stream
{-# LANGUAGE Arrows, TypeOperators #-}
import Prelude hiding (id, (.))
import SF
-- this is the timer - returns length of the tick
ticks :: () :-> Double
ticks = constant 1
-- Modelling the physics.
{-# LANGUAGE
TemplateHaskell,
Arrows
#-}
module Thing where
import Prelude hiding (id, (.))
import Control.Arrow
@Heimdell
Heimdell / ListAsFunctions.hs
Last active August 29, 2015 14:01
Proof, that lists could be modelled as functions.
{-# LANGUAGE RankNTypes #-}
type List a =
forall b.
(a -> b -> b) -> (b -> b)
nil :: List a
nil _ a = a
infixr 5 ><
@Heimdell
Heimdell / AST.hs
Created May 25, 2014 12:56
Lambda calculus interpreter (with atoms, integers, bifs & ability to force a value calculation) to play with.
module AST where
data AST
= [Name] :=> AST
| Name :? AST
| App [AST]
| Atom String
| Const Integer
| Force AST
@Heimdell
Heimdell / records.prolog
Last active August 29, 2015 14:02
Experimental prolog records-handling library.
:- use_module(library(lists)).
construct(Fields, Record)
:- Record =.. [record | Fields]
.
% synonym
%
make --> construct.
build --> destruct.
import Control.Applicative
import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Error
import Text.Printf
data Step