Skip to content

Instantly share code, notes, and snippets.

View sebastiaanvisser's full-sized avatar

Sebastiaan Visser sebastiaanvisser

View GitHub Profile
use std::time::Duration;
pub use OpF::*;
// Simple operation, with open recursion
#[derive(Debug, Clone)]
pub enum OpF<R> {
Once(String, Duration),
Par(Vec<R>),
Seq(Vec<R>),
Repeat { times: u32, cmd: Box<R> },
class MouseDir extends ReactishHook<number> {
cur = this.useState({ x: 0, y: 0 })
prev = this.useState({ x: 0, y: 0 })
init () {
document.addEventListener('mousemove', this.handle)
}
dispose () {
document.removeEventListener('mousemove', this.handle)
@sebastiaanvisser
sebastiaanvisser / walk.hs
Created August 18, 2017 12:17
AST walk
{-# LANGUAGE
DeriveFunctor
, DeriveFoldable
, DeriveTraversable
, StandaloneDeriving
, ViewPatterns
, PatternSynonyms
#-}
-- AST independent
@sebastiaanvisser
sebastiaanvisser / Profile.hs
Created October 2, 2015 12:28
Profiling HTTP requests.
module Main where
import Control.Applicative
import Control.Monad
import Data.Time.Clock
import Data.List
import Network.HTTP.Client
import System.IO
import qualified Data.ByteString.Lazy as Lazy
@sebastiaanvisser
sebastiaanvisser / Algebra.hs
Last active August 29, 2015 14:05
Composing F-algebras
{-# LANGUAGE GADTs, RankNTypes, TypeOperators, TupleSections #-}
module Algebra where
import Control.Category
import Control.Arrow
import Control.Applicative
import Label.Simple (get)
import Prelude hiding ((.), id)
import Generics.Combinator
@sebastiaanvisser
sebastiaanvisser / Utrecht.js
Created August 26, 2014 15:02
Utrecht-style alignment.
var user =
{ username : "foo bar"
, password : "super secret"
, sessionHistory : [ "Tue Aug 26 2014 16:58:14 GMT+0200 (CEST)"
, "Wed Aug 27 2014 16:58:14 GMT+0200 (CEST)"
, "Fri Aug 29 2014 16:58:14 GMT+0200 (CEST)"
]
, moneys : { amount : "-12"
, currency : "EUR"
}
@sebastiaanvisser
sebastiaanvisser / Failed.hs
Created August 26, 2014 09:12
Enforced monadic consumption.
{-# LANGUAGE
RebindableSyntax
, GADTs
, MultiParamTypeClasses
, FlexibleContexts
, FlexibleInstances
, FunctionalDependencies
, TypeFamilies
, UndecidableInstances
#-}
@sebastiaanvisser
sebastiaanvisser / Label.hs
Last active August 29, 2015 14:00
Generic Label datatype. Generalizes Point by adding a separate context for modification, allowing for things like traversals. Additionally, removed the categories and replaced them with monads instead.
{- | The Label data type which generalizes the different lenses. -}
{-# LANGUAGE GADTs, FlexibleInstances #-}
module Data.Label.Label
(
-- * The point data type that generalizes lens.
Label
, get
, modify
, set
@sebastiaanvisser
sebastiaanvisser / gist:9909890
Created April 1, 2014 08:06
Paths, lenses combined with a name.
{-# LANGUAGE
Arrows
, FlexibleInstances
, MultiParamTypeClasses
, TypeOperators
#-}
module Path where
import Control.Arrow
import Control.Category
@sebastiaanvisser
sebastiaanvisser / gist:9785886
Created March 26, 2014 15:22
Higher order functor/applicative/foldable/traversable.
{-# LANGUAGE
DeriveFunctor
, GADTs
, GeneralizedNewtypeDeriving
, TypeOperators
, TypeFamilies
, RankNTypes
#-}
module HigherOrder where