Skip to content

Instantly share code, notes, and snippets.

@sebfisch
sebfisch / jobs.markdown
Last active Aug 29, 2015
Implementation of the Jobs Puzzle in Curry
View jobs.markdown

Implementation of the Jobs Puzzle in Curry

by Sebastian Fischer, January 2015

Verbal problem description

There are four people: Roberta, Thelma, Steve, and Pete.

@sebfisch
sebfisch / rubykara-kiel.txt
Last active Dec 14, 2015
Hilfsprogramm zur Vereinfachung und Erweiterung von Ruby Kara: http://www.swisseduc.ch/informatik/karatojava/rubykara/
View rubykara-kiel.txt
Die RubyKara Erweiterung aus Kiel gibt es jetzt hier: https://github.com/sebfisch/rubykara-kiel
@sebfisch
sebfisch / DarcsDialog.markdown
Last active Dec 14, 2015
A dialog on how to manage patches with Darcs.
View DarcsDialog.markdown

A Dialog on How to Manage Patches with Darcs

Fred: So, you know Darcs?

Lisa: Sure.

Fred: I heard it is quite flexible in managing patches. Wanna show me?

Lisa: Ok, let's make a new repository for some imaginary project.

View Mappers.hs
{-
A German blog post translating Java code for the build tool Ant to Scala
http://funktionale-programmierung.de/2013/02/26/scala-java-ant.html
made me translate the Scala code to Haskell. I added combinators for binary
composition of mappers as well as a unit mapper for one of them. The code is
still shorter. I find the Haskell version more readable because expressions
and their types are separate rather than interleaved as in Scala.
@sebfisch
sebfisch / gist:3757918
Created Sep 20, 2012
Comparing Snap's and Yesod's Template Languages Heist and Hamlet
View gist:3757918

Comparing Snap's and Yesod's Template Languages Heist and Hamlet - and HSP

Currently, Snap and Yesod are the two most active web frameworks for Haskell. In this document, I compare the template languages used by those frameworks for generating HTML.

Both template languages let programmers write markup directly in a markup language rather than generating it from within Haskell. Compared with static HMTL, template languages support substitution to dynamically determine parts of the content of the generated page.

[Heist] and [Hamlet] support different constructs to generate content dynamically. They also differ regarding their syntax for static content.

@sebfisch
sebfisch / replace-classes-in-apk.sh
Created May 22, 2012
Replaces classes in Android Package Files
View replace-classes-in-apk.sh
#!/bin/bash
# Replaces classes in Android Package Files
# (c) Sebastian Fischer, CC-BY
# Can be used to rebuild an App with a modified version of a used library,
# as required for closed works that link to an LGPL library.
# Depends on: https://code.google.com/p/dex2jar/
@sebfisch
sebfisch / gist:2235780
Created Mar 29, 2012
Laymans explanation of delimited continuations with examples of using them for exception handling and nondeterministic programming.
View gist:2235780

Delimited Continuations

Delimited continuations manipulate the control flow of programs. Similar to control structures like conditionals or loops they allow to deviate from a sequential flow of control.

We use exception handling as another example for control flow manipulation and later show how to implement it using delimited continuations. Finally, we show that nondeterminism can also be expressed using delimited continuations.

Exception Handling

@sebfisch
sebfisch / ListTransformer.hs
Created Dec 26, 2011
Lazy functions on lists with parallel and sequential composition using standard type classes.
View ListTransformer.hs
module ListTransformer where
import Control.Applicative
import Control.Arrow
import Control.Category
import Prelude hiding ( id, (.) )
data ListConsumer a b
= Done b
@sebfisch
sebfisch / interp.idr
Created Aug 17, 2011
Type-safe Interpreter in Idris
View interp.idr
tyFun : Set -> Set -> Set;
tyFun A T = A -> T;
using (G:Vect Set n) {
data Expr : Vect Set n -> Set -> Set where
Var : (i:Fin n) -> Expr G (vlookup i G)
| Val : T -> Expr G T
| Lam : Expr (A::G) T -> Expr G (tyFun A T) -- using `A -> T` directly fails
| App : Expr G (A -> T) -> Expr G A -> Expr G T
@sebfisch
sebfisch / ArrowVsApplicative.hs
Created Jul 31, 2011
Comparison of Arrow and Applicative classes by implementing file IO
View ArrowVsApplicative.hs
{-
example from
http://blog.downstairspeople.org/2010/06/14/a-brutal-introduction-to-arrows/
rewritten using Applicative instance from
http://cdsmith.wordpress.com/2011/07/30/arrow-category-applicative-part-i/