Skip to content

Instantly share code, notes, and snippets.

@alexandru
alexandru / task-proposal.md
Last active April 1, 2018 14:57
Task: A diverging design from Future and Scalaz Task
@puffnfresh
puffnfresh / gist:5852cd41c30604342fa2
Created October 29, 2015 04:20
null.asInstanceOf[Int].asInstanceOf[String]
scala> null.asInstanceOf[Int]
res0: Int = 0
scala> 0.asInstanceOf[String]
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
... 33 elided
scala> null.asInstanceOf[Int].asInstanceOf[String]
res2: String = null
@leque
leque / freer-monad.scm
Last active May 11, 2016 01:35
Freer monad in Scheme
;;;; Freer monad in Scheme
;;;; See also
;;;; * "Freer monads, more extensible effects"
;;;; http://dl.acm.org/citation.cfm?doid=2804302.2804319
;;;; * Free monad in Scheme https://gist.github.com/wasabiz/951b2f0b22643a59aeb2
(use gauche.record)
(use util.match)
;;; data Freer f a where
;;; Pure :: a -> Freer f a
@pocketberserker
pocketberserker / scala_functional_meeting_slide.md
Created July 25, 2015 04:15
関数型Scalaの集い発表資料

何か作ろうと思ったけど無理だったので使ったライブラリ紹介

自己紹介

icon

  • なかやん・ゆーき / ぺんぎん / もみあげ
  • @pocketberserker / id:pocketberserker
  • Microsoft MVP for F# .NET (2015/04/01~ 2016/03/31)
  • そういえば Scala でアプリケーション作ったことない…
@pocketberserker
pocketberserker / questionnaire.md
Created July 24, 2015 09:12
関数型Scalaの集いアンケート結果

関数型Scalaの集いアンケート結果

Q1. scalazを使用していますか?

  • 仕事でも趣味でも使ってる 8
  • 仕事で使っている 10
  • 趣味で使っている 29
  • 使っていない 79

Q2. Functional Programming in Scalaを持っていますか?

@travisbrown
travisbrown / MonadADT.scala
Last active April 28, 2017 02:34 — forked from kevinmeredith/MonadADT.scala
Sequencing through Monad with ADT
// Given the following ADT:
sealed trait Status
case object One extends Status
case object Two extends Status
case object Three extends Status
// They represent states. The natural progression, for this
// example, is : One -> Two -> Three
@myuon
myuon / NSemiring.hs
Created July 21, 2015 13:44
Near Sermiring and MonadPlus
{-# LANGUAGE Rank2Types, ScopedTypeVariables #-}
import Prelude hiding ((<*>), abs)
import qualified Control.Applicative as A
import Control.Monad
import Test.QuickCheck
class NearSemiring m where
(<+>) :: m a -> m a -> m a
zero :: m a
(<*>) :: m a -> m a -> m a
@pchiusano
pchiusano / streams.scala
Last active August 29, 2015 14:23
Stream API
package streams
trait Free[+F[_],+A] {
import Free._
def flatMap[F2[x]>:F[x],B](f: A => Free[F2,B]): Free[F2,B] = Bind(this, f)
def map[B](f: A => B): Free[F,B] = Bind(this, f andThen (Free.Pure(_)))
}
object Free {
case class Pure[A](a: A) extends Free[Nothing,A]
case class Eval[F[_],A](fa: F[A]) extends Free[F,A]
@y-yu
y-yu / applicative.scala
Created June 7, 2015 12:03
Applicative.scala
trait Applicative[F[_]] {
def pure[A](a: A): F[A]
def apply[A, B](f: F[A => B], a: F[A]): F[B]
}
trait Traversable[T[_], F[_]] {
def traverse[A, B](f: A => F[B], a: T[A]): F[T[B]]
}
trait Monoid[A] {
scala> :paste
// Entering paste mode (ctrl-D to finish)
def impl[T: c.WeakTypeTag](c: Context): c.Tree = {
import c.universe._
def subs = weakTypeOf[T].typeSymbol.asClass.knownDirectSubclasses
val subs1 = subs
println(subs1)
val global = c.universe.asInstanceOf[tools.nsc.Global]
def checkSubsPostTyper = if (subs1 != subs)