Skip to content

Instantly share code, notes, and snippets.

View gtani7's full-sized avatar

Gene Tani gtani7

  • north of Seattle
  • 16:43 (UTC -12:00)
View GitHub Profile
module TypeChecker where
type Vname = String
data Vexp = Var Vname
| Lambda Vname Vexp
| Ap Vexp Vexp
| Let [Vname] [Vexp] Vexp
| Letrec [Vname] [Vexp] Vexp
@kazu-yamamoto
kazu-yamamoto / gist:2921996
Created June 13, 2012 05:16
String vs ByteString vs Text
{-# LANGUAGE OverloadedStrings #-}
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.ByteString.Char8 ()
import Data.Text (Text)
import qualified Data.Text as T
foo :: String -> Int
@23Skidoo
23Skidoo / HashTable.hs
Created October 22, 2011 08:54
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
@dcsobral
dcsobral / gist:1120811
Created August 2, 2011 18:11
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
/* NSC -- new Scala compiler
* Copyright 2005-2010 LAMP/EPFL
* @author Paul Phillips
*/
package scala.tools.nsc
package util
import java.util.concurrent.{ Future, TimeUnit }
import java.lang.reflect.{ Modifier, Field, Method => JMethod }
@razie
razie / scala-profiles.markdown
Created September 24, 2010 15:35
Scala abuses

Scala is a wonderful language, with a specification of a size comparable with that of Java. Overall, the specification is simpler than C++. Why then do some feel intimidated by its expressiveness?

Scala can generate complex constructs. There are some features of the language that, if not used properly, can negatively influence one's perception of its simplicity and generate a waste of many an hour of a frustrated developer.

Newcomers from simply typed, object-oriented, structured languages do not have a full grasp of all the features of scala and their effects or benefits, and they may be very surprised if others on their team use them.

One thing to have when starting or using scala is a readily available bible. I recommend "Programming in Scala", the .pdf version, an easily searcheable language reference.

The scala style guide is very good. Here we will describe the advanced features of the language, which are aimed at library-developers and should not b