Skip to content

Instantly share code, notes, and snippets.

View mads-hartmann's full-sized avatar

Mads Hartmann mads-hartmann

View GitHub Profile
@mads-hartmann
mads-hartmann / demystify_state_monad.hs
Created September 21, 2011 21:26
This is an attempt to de-mystify how Control.Monad.State.get seems to magically create a State out of nothing.
{-
Dear reader,
This is an attempt to de-mystify how Control.Monad.State.get seems to
magically create a State out of nothing.
Here's an example taken from the documentation:
tick :: State Int Int
tick = do
@mads-hartmann
mads-hartmann / sbt_error.txt
Created September 1, 2011 00:17
sbt error
Sooo, what is happening here?
[error] error while loading Diff, class file needed by Diff is missing.
[error] reference type Serializable of package scala refers to nonexisting symbol.
[error] class file needed by Diff is missing.
[error] reference type Serializable of package scala refers to nonexisting symbol.
[error] two errors found
[debug] Compilation failed (CompilerInterface)
Compilation failed
at xsbt.CompilerInterface.run(CompilerInterface.scala:93)
@mads-hartmann
mads-hartmann / higher-rank polymorphic function with type bounds.scala
Created August 11, 2011 14:26
Attempt to create a higher-rank polymorphic function with type bounds
/*
I want to use a higher-rank polymorphic function when transforming an AST to generalize the
'traversal' so it can be separated from the actual transformation of each node.
This snippet of code doesn't quite capture my use case but it provokes the same compile error
as I get here: https://gist.github.com/1139579
*/
trait ~>[F[_],G[_], -UpperBound] {
def apply[A <: UpperBound](a: F[A]): G[A]
@mads-hartmann
mads-hartmann / ast_transformation.scala
Created August 11, 2011 13:00
Attempt to do AST Transformation
#!/bin/sh
exec scala "$0" "$@"
!#
/*
Subset of our Simple Java AST
*/
sealed abstract class SJStatement
case class SJAssert (assertion : SJExpression) extends SJStatement
@mads-hartmann
mads-hartmann / syntax.selfml
Created August 8, 2011 19:34
Scala syntax for Chocolatapp (generated)
(root source.scala
(include @storage-modifiers)
(include @keywords)
(include @declarations)
(include @inheritance)
(include @imports)
(include @comments)
(include @block-comments)
(include @strings)
(include @initialization)
@mads-hartmann
mads-hartmann / scala.scala
Created August 8, 2011 19:29
just a scala file to show a syntax bug in chocolatapp
package org.lifty.engine
import java.io.File
import org.lifty.engine._
import scalaz._
import Scalaz._
/* This class is just used for debugging purposes */
object Main {
@mads-hartmann
mads-hartmann / coding music
Created July 29, 2011 16:38
When I asked for music suitable as background music while coding, this is the answers I got
@heiflo: Deep Mix Moscow Radio www.deepmix.eu
@behaghel: JJ Cale
@franztaptanium: Steps from Hell
@peyloW: Deine Lakaien, Raubtier, Timoteij, VNV Nation, Dragon Force
@TwistedChaz: Portico Quartet - Knee-Deep in the North Sea (Album)
@ArmyOfBruce: Orbital
@tylerweir: di.fm
__________________________________________________
Project definition:
__________________________________________________
version := "0.7"
resolvers += "Scala Tools Releases" at "http://scala-tools.org/repo-releases/"
libraryDependencies += "org.scalatest" % "scalatest" % "1.3" % "test"
// Attempt to do tail-recursion in JavaScript without getting a stack-overflow exception.
// This is horribly slow because of all of the extra stack frames pr. thunk.
// What would you call this? Lazy-tail-recursion?
var tailrec = function(f) {
for(var x = f() ; typeof x == "function" ; x = x()){}
return x;
};
var counter = function(){
Jun 8 08:21:15 localhost Unknown[305]: Launching the Language Chooser for an OS Install
Jun 8 08:21:24 localhost configd[102]: bootp_session_transmit: bpf_write(en1) failed: Network is down (50)
Jun 8 08:21:24 localhost configd[102]: DHCP en1: INIT transmit failed
Jun 8 08:21:24 localhost LCA[306]: Bookmark failed to issue extension for item (depth=4000): No such file or directory
Jun 8 08:21:28 localhost LCA[306]: Using keyboard layout 9
Jun 8 08:21:28 localhost Unknown[307]: Keyboard Layouts: duplicate keyboard layout identifier -16899.
Jun 8 08:21:28 localhost Unknown[307]: Keyboard Layouts: keyboard layout identifier -16899 has been replaced with -28673.
Jun 8 08:21:28 localhost Unknown[307]: Keyboard Layouts: duplicate keyboard layout identifier -16900.
Jun 8 08:21:28 localhost Unknown[307]: Keyboard Layouts: keyboard layout identifier -16900 has been replaced with -28674.
Jun 8 08:21:28 localhost LCA[306]: Found primary language hint "en"