Skip to content

Instantly share code, notes, and snippets.

apply :: (t -> a) -> (t -> b) -> (a, b)
apply f g x = (f x, g x)

Useful Scalac Flags

So, there have been some discussions and angry tweets recently about irritating Scala "features" (like value discarding and auto-tupling) that can actually be turned off by selecting the right compiler flag in conjunction with -Xfatal-warnings. I highly recommend a set of options something like those below.

scalacOptions ++= Seq(
  "-deprecation",           
  "-encoding", "UTF-8",       // yes, this is 2 args
  "-feature",                
 "-language:existentials",
... = begin
suc (a + suc b)
==< cong suc (lemma2 a b) >
suc (suc (a + b))
==< cong (suc.suc) (comm a b) >
suc (suc (b + a))
==< cong suc (sym (lemma2 b a)) >
suc (b + suc a)
[]
suc (a + suc b) == suc (b + suc a)
^
|
|
suc (suc (a + b)) == suc (b + suc a)
^
|
|
suc (suc (a + b)) == suc (suc (b + a))
^
module Printf
%default total
data Format = FInt Format -- %d
| FString Format -- %s
| FOther Char Format -- [a-zA-Z0-9]
| FEnd --
format : List Char -> Format

This is my recommended path for learning Haskell.

Something to keep in mind: don't sweat the stuff you don't understand immediately. Just keep moving.

Primary course

Installing Haskell

Ubuntu PPA

require 'tire'
require 'nobrainer'
NoBrainer.connect 'rethinkdb://server/company'
class Employee
include NoBrainer::Document
field :name
field :title
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
gem 'sqlite3'
GEMFILE
@hmaurer
hmaurer / groups.p6
Last active August 29, 2015 14:07 — forked from masak/groups.p6
role Group {
method elements { ... }
method id { ... }
method op($l, $r) { ... }
}
macro assert($fact) {
quasi {
die "FAILED: ", $fact.Str
unless {{{$fact}}};
@hmaurer
hmaurer / a3gis.purs
Last active August 29, 2015 14:13 — forked from joneshf/a3gis.purs
module A3gis where
import Data.Traversable
import Data.Map
import Data.Maybe
foo :: forall k v. (Eq v, Ord k) => Map k v -> Map k v -> Maybe (Map k v)
foo m1 m2 = sequence $ unionWith go (Just <$> m1) (Just <$> m2)
where
go x y = if x == y then x else Nothing