Skip to content

Instantly share code, notes, and snippets.

import scala.language.higherKinds
import scala.language.implicitConversions
trait Forall[M[_]] {
def apply[A]: M[A]
}
trait Maybe[A] extends Forall[({ type F[R] = (A => R, => R) => R })#F]
object Maybe {
@ponkotuy
ponkotuy / gist:5379540
Last active December 16, 2015 04:49
Akka ActorでPipeline処理
import scala.concurrent.Await
import scala.concurrent.duration._
import akka.actor._
import akka.pattern.gracefulStop
object Main extends App {
implicit val duration = 5.seconds
val system = ActorSystem()
// 初期化時に、データを渡すAcotrRefを引数にして初期化する
val ref = {
@ForbesLindesay
ForbesLindesay / Real World Specification.md
Last active January 4, 2022 22:41
Functional Programming from the perspective of a JavaScript Programmer.

Real World Specification

(aka "Algebraic JavaScript Specification")

This project specifies the behavior of a number of methods that may optionally be added to any object. The motivation behind this is to encourage greater code reuse. You can create functions that just rely on objects having implementations of the methods below, and in doing so you can make them work with a wide variety of different, but related data structures.

Definitions

For the purposes of this, spec, an "entity" is an object that has an [[equivalent]] operation (see bellow) and may implement some or all of the other methods.

// -*- coding: utf-8 -*-
// ==UserScript==
// @name They are all 17 years old
// @author HIRATA Yasuyuki <[email protected]>
// @namespace http://yasu.asuka.net/
// @version 1.1.0
// @include http://www.google.tld/search?*
// @include https://www.google.tld/search?*
// @released 2013-04-23
// @updated 2013-04-30
@fumieval
fumieval / IndexedTools.hs
Created May 1, 2013 13:59
Indexed free monadでCoqのタクティクスのようなものを実装
{-# LANGUAGE GADTs, TemplateHaskell #-}
module IndexedTools where
import Control.Monad.Indexed
import Language.Haskell.Meta
import Language.Haskell.TH
import Language.Haskell.TH.Quote
data IxFree f i j x where
Pure :: a -> IxFree f i i a
import com.twitter.util.{Future => TwFuture}
import scala.concurrent.{Future => ScFuture, promise => ScPromise}
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = {
val prom = ScPromise[T]
twFuture.onSuccess { res: T =>
prom.success(res)
}
twFuture.onFailure { t: Throwable =>
prom.failure(t)
}
@voluntas
voluntas / vagrant.rst
Last active September 21, 2020 22:11
Vagrant コトハジメ
@drexin
drexin / Macros.scala
Last active October 27, 2016 09:41
macros to get current file and line, inspired by ruby's __FILE__ and __LINE__
import java.io.File
import language.experimental.macros
import scala.reflect.macros.Context
object Macros {
def LINE: Int = macro lineImpl
def lineImpl(c: Context): c.Expr[Int] = {
import c.universe._
@halcat0x15a
halcat0x15a / monad.md
Last active December 17, 2015 06:08
Monad Comprehension in Clojure

ぼくのかんがえたさいきょうのMonad Syntax in Clojure

タイトル通りです。

最近はClojureを書いていて、モナドがなくてもThreading Macroがあればまあいいかなと思うようになってきたのですが、

Clojureのprotocolで型クラス的な多態な関数を作る

この記事に触発されたので、なにか書いてみます。

@ympbyc
ympbyc / FunctionalJs.md
Last active November 2, 2024 00:52
Functional JavaScript

Functional JavaScript

2013 Minori Yamashita [email protected]

-- ここにあなたの名前を追記 --

目次