This is my recommended path for learning Haskell.
- GitHub Staff
- @belinburgh
This file contains hidden or 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
require 'tire' | |
require 'nobrainer' | |
NoBrainer.connect 'rethinkdb://server/company' | |
class Employee | |
include NoBrainer::Document | |
field :name | |
field :title |
This file contains hidden or 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
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 file contains hidden or 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
suc (a + suc b) == suc (b + suc a) | |
^ | |
| | |
| | |
suc (suc (a + b)) == suc (b + suc a) | |
^ | |
| | |
| | |
suc (suc (a + b)) == suc (suc (b + a)) | |
^ |
This file contains hidden or 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
... = 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) | |
[] |
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",
This file contains hidden or 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
apply :: (t -> a) -> (t -> b) -> (a, b) | |
apply f g x = (f x, g x) |
This file contains hidden or 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
sumUpTo :: Int -> [(Int, Int)] | |
sumUpTo n = map (\x -> (x, n - x)) [0..n] | |
mult xs ys = do | |
cs <- map sumUpTo [0..maxCoef] | |
return (sum $ map g $ filter f cs) | |
where | |
maxCoef = length xs + length ys - 2 | |
f (x, y) = x < length xs && y < length ys | |
g (x, y) = (xs !! x) * (ys !! y) |
This file contains hidden or 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
// This is the structure of the binary nbt file | |
TAG_Compound('Level') { | |
TAG_Compound('nested compound test') { | |
TAG_Compound('egg') { | |
TAG_String('name'): 'Eggbert' | |
TAG_Float('value'): 0.5 | |
} | |
TAG_Compound('ham') { | |
TAG_String('name'): 'Hampus' | |
TAG_Float('value'): 0.75 |
This file contains hidden or 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
// Index of maximum: j | |
int j = 0; | |
for (int i = 1; i < array.length; i++) { | |
if (array[i] > array[j]) j = i; | |
} |