Skip to content

Instantly share code, notes, and snippets.

View quelgar's full-sized avatar
🇦🇺

Lachlan O'Dea quelgar

🇦🇺
View GitHub Profile
@quelgar
quelgar / jsmap.hs
Last active February 22, 2017 14:54
Is Javascript's array map function basically a comonadic cobind (=>> in Haskell)? Have a look as the jsmap function below.
-- Inspired by http://nedbatchelder.com/blog/201301/stupid_languages.html
-- which describes how the Javascript array.map function seems weird
-- and also http://blog.sigfpe.com/2008/03/comonadic-arrays.html
-- which describes the comonad for arrays
import Data.Array
import Data.Char
class Functor w => Comonad w where
(=>>) :: w a -> (w a -> b) -> w b
@quelgar
quelgar / filesizerer.scala
Created July 15, 2012 01:45
Simple Scala example of a pure functional program that does I/O
/*
* Referentially transparent program to print the size of files.
*
* Techniques inspired by:
* "Dead-Simple Dependency Injection"
* Rúnar Óli Bjarnason
* Northeast Scala Symposium, 2012
*
* To run: "scala filesizerer.scala"
* When prompted, enter a file name.
@quelgar
quelgar / gist:2497604
Created April 26, 2012 08:24
sbt setting to not check scala-tools
externalResolvers <<= resolvers map { rs =>
Resolver.withDefaultResolvers(rs, scalaTools = false)
}