Skip to content

Instantly share code, notes, and snippets.

View gtani7's full-sized avatar

Gene Tani gtani7

  • north of Seattle
  • 18:20 (UTC -12:00)
View GitHub Profile
@gtani7
gtani7 / gist:1312269
Created October 25, 2011 10:50
Dependent method types
scala> trait Foo { type Bar }
defined trait Foo
scala> def withFoo(foo: Foo): foo.Bar = // The return type depends on the parameter!
| sys.error("Not yet implemented")
withFoo: (foo: Foo)foo.Bar
@gtani7
gtani7 / gist:1312277
Created October 25, 2011 10:52 — forked from dcsobral/gist:1120811
Existential _ vs Higher-kind _
scala> def f[A[_] <: Seq[_]](f: A[Int]) = f.head
f: [A[_] <: Seq[_]](f: A[Int])A
scala> def f[A[_] <: Seq[t] forSome { type t }](f: A[Int]) = f.head
f: [A[_] <: Seq[_]](f: A[Int])A
scala> def f[A[t] <: Seq[_] forSome { type t}](f: A[Int]) = f.head
f: [A[t] <: Seq[_] forSome { type t }](f: A[Int])A
@gtani7
gtani7 / HashTable.hs
Created October 25, 2011 11:52 — forked from 23Skidoo/HashTable.hs
n-gram
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
import qualified Data.Sequence as S
import qualified Data.Foldable as F
import Control.Monad
import Data.Hashable
import Data.Sequence ((|>), ViewL(..))
import Data.Function (on)
import qualified Data.ByteString.Char8 as B
import qualified Data.HashTable.IO as H
import Data.List