This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract sig Event {} | |
one sig 卒業式 extends Event {} | |
one sig 海外旅行 extends Event {} | |
one sig 入社式 extends Event {} | |
one sig 花見 extends Event {} | |
one sig ハイキング extends Event {} | |
abstract sig Item {} | |
one sig 靴 extends Item {} | |
one sig ハンカチ extends Item {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.Instant | |
import akka.NotUsed | |
import akka.actor.ActorSystem | |
import akka.stream.scaladsl.{Flow, Keep, Sink, Source} | |
import akka.stream.{ActorMaterializer, KillSwitches} | |
import akka.testkit.TestKit | |
import akka.util.Timeout | |
import org.scalatest.{FreeSpecLike, Matchers} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Foo(a: Int, s: String) | |
case class Bar(a: Int, s: String) | |
val foo = Foo(100, "hey!") | |
// foo: Foo = Foo(100,hey!) | |
val bar = Bar.tupled(Foo.unapply(foo).get) | |
// bar: Bar = Bar(100,hey!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
import scala.language.implicitConversions | |
import scala.language.reflectiveCalls | |
trait Functor[F[_]] { | |
def map[A, B](m: F[A])(f: A => B): F[B] | |
} | |
implicit def functorOps[F[_] : Functor, A](self: F[A]) = new { | |
def map[B](f: A => B): F[B] = implicitly[Functor[F]].map(self)(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
import scala.language.implicitConversions | |
import scala.language.reflectiveCalls | |
trait Functor[F[_]] { | |
def map[A, B](m: F[A])(f: A => B): F[B] | |
} | |
implicit def functorOps[F[_] : Functor, A](self: F[A]) = new { | |
def map[B](f: A => B): F[B] = implicitly[Functor[F]].map(self)(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* "FreeモナドでListを表現する" の理解のため | |
* 元のコードで使用されているScalazのFreeをシンプルな実装のFreeに置き換えたもの. | |
* | |
* 参照 | |
* Freeモナド in Scala: http://yuroyoro.hatenablog.com/entry/2012/11/16/171834 | |
* FreeモナドでListを表現する: http://d.hatena.ne.jp/xuwei/20131123/1385215528 | |
* - scalaz 7.1版: https://gist.github.com/xuwei-k/31c2317a5b9035932399 | |
*/ | |
import scalaz._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Free + Coyoneda で Option(Maybe) Monad 的なもの. | |
* | |
* OptionをFreeで実現するメリットは特に無いですが | |
* Coyoneda経由のFreeまでのリフトの流れ | |
* インタプリタの働きなどを見る学習用です | |
* | |
* twitter: @awekuit | |
*/ | |
import scala.language.higherKinds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import breeze.linalg.DenseVector | |
import breeze.math._ | |
import edu.emory.mathcs.jtransforms.fft.{DoubleFFT_1D => jFFT} | |
def show(v1 : Array[_], v2 : Array[_], v3 : Array[_]) { | |
println("v1: " + v1.mkString(", ")) | |
println("v2: " + v2.mkString(", ")) | |
println("v3: " + v3.mkString(", ")) | |
} |