Skip to content

Instantly share code, notes, and snippets.

@nlinker
nlinker / freefrp.js
Created March 2, 2017 08:10 — forked from jkpl/freefrp.js
Free monad based thread simulation and FRP constructs written in JavaScript. http://stuff.lepovirta.org/r/freefrp/
// Free monad based thread simulation and FRP constructs written in JavaScript
// First, we need some way to express lazy values and actions.
// We can use zero-argument functions for this purpose: call the function and
// you get the value. We also need to compose lazy values/actions. For that
// we have bindLazy function. Lazy values are not expected to be pure
// in this program: evaluating a lazy value/action at different times can produce
// a different value.
Хм... Сложно согласиться с
> в Haskell монады -- это способ записать _императивный_ код в полностью декларативном языке.
Наверное если смотреть технически - то это верное высказывание.
Но оно скрывает суть. Скрывает смысл "пользы от монад".
Насколько я помню...
Монады - они и в Африке монады. В независимости от того какой язык - чисто декларативный/функциональный или нет.
@nlinker
nlinker / build.sbt
Created August 5, 2016 13:59 — forked from eed3si9n/build.sbt
Source dependency
lazy val scalaJson = ProjectRef(uri("git://github.com/mdedetrich/scala-json-ast.git#c5ee84"), "scalaJsonASTJVM")
lazy val root = (project in file(".")).
dependsOn(scalaJson).
settings(inThisBuild(List(
organization := "com.example",
scalaVersion := "2.11.8"
)),
name := "sourceDeps"
)
@nlinker
nlinker / gist:45b33c2584f9cb6ddd7b072878aa412a
Created May 13, 2016 22:46 — forked from pcapriotti/gist:1761136
Composition of free monads
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
import Control.Monad
import Control.Monad.Free
class (Functor f, Functor g, Functor h) => Compose f g h | f g -> h where
compose :: f x -> g y -> Free h (Free f x, Free g y)
compose f g = return (liftF f, liftF g)
composeF :: Compose f g h => Free f x -> Free g x -> Free h x
trait Module {
type shape
}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Lens -- lens
import Control.Monad.IO.Class -- transformers
import Control.Monad.Trans.AWS -- amazonka
import Network.AWS.EC2 -- amazonka-ec2
main :: IO ()
@nlinker
nlinker / App.java
Last active March 16, 2020 10:05
Embedded Jetty + Jersey + Guice
package com.vertigo.service.rest.search;
import java.util.EnumSet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import com.vertigo.service.rest.search.filter.GuiceFilter;
import com.vertigo.service.rest.search.listener.GuiceServletContextListener;
@nlinker
nlinker / RedBlackTree.hs
Created October 16, 2015 11:37 — forked from rampion/RedBlackTree.hs
red-black trees in haskell, using GADTs and Zippers
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module RedBlackTree where
data Zero
data Succ n
type One = Succ Zero
data Black
@nlinker
nlinker / example.sh
Last active August 29, 2015 14:26 — forked from tristanbes/example.sh
Install Graphite on Debian Server
# Installing graphite dependencies
apt-get install -y python2.6 python-pip python-cairo python-django python-django-tagging
apt-get install -y libapache2-mod-wsgi python-twisted python-memcache python-pysqlite2 python-simplejson
pip install whisper
pip install carbon
pip install graphite-web
# Setup a vhost by grabbing the example the graphite team released on their repo.
# In this file, you'll provide the url used to access to your Graphite dashboard
wget https://raw.github.com/tmm1/graphite/master/examples/example-graphite-vhost.conf -O /etc/apache2/sites-available/graphite
@nlinker
nlinker / install-ghc.md
Last active August 29, 2015 14:25 — forked from yantonov/install-ghc-ubuntu.md
how to install latest GHC 7.10.1 + cabal 1.22.3.0 from source on ubuntu

How to install latest GHC 7.10.1 + cabal 1.22.3.0 from source on ubuntu

for your convinience these instuction is available as:
gist
git repo

ghc

ubuntu prerequisites