Skip to content

Instantly share code, notes, and snippets.

@kmizu
kmizu / TypeConstructorCurrying.scala
Created September 25, 2011 15:03
Scala's type constructor is not "curried" form. In this example, it is explained that we can emulate type constructor currying using abstract type member.
trait TF {
type Apply[A]
}
type Curry2[F[_, _]] = TF { type Apply[X] = TF { type Apply[Y] = F[X, Y] } }
type Curry3[F[_, _, _]] = TF { type Apply[X] = Curry2[(TF { type Apply[Y, Z] = F[X, Y, Z] })#Apply] }
// ...
type CurriedMap = Curry2[Map]
val x: CMap#Apply[String]#Apply[Int] = Map("x" -> 1, "y" -> 1) //It is valid code.
@stepchowfun
stepchowfun / merger.py
Last active September 3, 2023 03:04
My three-way merge algorithm, originally designed for 6.033 DP2.
#!/usr/bin/python -O
################################################################################
################################################################################
#
# State-Based Text Merging Algorithm
# For 6.033 Design Project 2
# TA: Katherine Fang
# 9 May 2012
#
@nacyot
nacyot / 2013-03-04-ruby-trivias-you-should-know-4.md
Last active January 18, 2024 02:11
알아두면 도움이 되는 55가지 루비 기법
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@jkpl
jkpl / Main.scala
Last active February 5, 2024 08:29
Ways to pattern match generic types in Scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x