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 DataKinds, GADTs, KindSignatures #-}
data RedBlack :: (Bool -> *) where
Red :: RedBlack 'False -> RedBlack 'True
Black :: RedBlack a -> RedBlack b
Stop :: RedBlack a
test = Red $ Black $ Red $ Stop
@Heimdell
Heimdell / Card.hs
Last active January 17, 2016 21:35
Bla.
{-# LANGUAGE TemplateHaskell #-}
module Card where
import Test.QuickCheck
import Control.Lens
data Card = Of { _rank :: Rank, _suit :: Suit }
module InvertedReg where
import Control.Monad
import Control.Applicative
import Data.Monoid
data Generator s = Gen { generate :: [s] }
require 'gtk3'
class App
def self.create &block
@@framestack = [Gtk::Window.new]
@@registration_on = true
flow { self.instance_eval &block }
@Heimdell
Heimdell / fun.js
Last active November 7, 2015 19:21
not_implemented = function () {
throw "Implement me!"
}
map_list = not_implemented
map_nullable = not_implemented
map_function = not_implemented
assert_equal = function (x, y) {
@Heimdell
Heimdell / AST.hs
Last active October 14, 2015 10:20
{-# LANGUAGE DeriveFunctor #-}
module AST where
data AST var
= Constant String
| Variable var String
| (:->) [var] (AST var)
| Call (AST var) [AST var]
let getline return =
getchar -> c:
if equal c "\n" ?
return ""
else
getline -> s:
return (+ c s);
let putline string next =
@Heimdell
Heimdell / partial.rkt
Last active October 11, 2015 11:54
Parser, which consumes input partially.
#lang racket
; await (s -> (s, parser))
; yield (result, parser)
; stop (error)
(define (await state-transform) `(await ,state-transform))
(define (yield result next) `(yield ,result ,next))
(define (stop error) `(stop ,error))
@Heimdell
Heimdell / nua.hs
Last active October 9, 2015 18:53
{-# LANGUAGE RankNTypes #-}
import Data.Traversable (for)
import Data.Functor.Identity
import Data.Functor.Constant
type Lens s t a b = forall f . Applicative f => (a -> f b) -> (s -> f t)
#lang racket
(define (partition good? list return)
(match list
[(list)
(return `() `())]
[(list head tail ...)
(partition good? tail (λ (accepted rejected)