Skip to content

Instantly share code, notes, and snippets.

package checked.exceptions.suck;
public class RuntimeAllTheThingsHelper {
public interface RuntimeAllTheThings<T> {
T runLikeABoss() throws Exception;
}
public static <T> T runLikeABoss(RuntimeAllTheThings<T> block) {
try {
@disolovyov
disolovyov / gist:4126329
Created November 21, 2012 17:36
Lambdabot on OS X with Homebrew
brew install readline && \
cabal install readline --extra-include-dirs=/usr/local/Cellar/readline/6.2.4/include --extra-lib-dirs=/usr/local/Cellar/readline/6.2.4/lib --configure-option=--with-readline-includes=/usr/local/Cellar/readline/6.2.4/include --configure-option=--with-readline-libraries=/usr/local/Cellar/readline/6.2.4/lib && \
cabal install lambdabot
@disolovyov
disolovyov / resources.md
Created October 25, 2012 06:43
Resources for FP class @ 8-bit Panda

Functional Programming

Below is the material for lectures and sessions we've had so far, crammed into one file. When only concrete parts of a book chapter are required for understading, it is marked as such in parenthesis. Which is not to say it is forbidden to read whole chapters and learn new things outside of class.

Lecture: Essential Ideas

  • Functional programming
@disolovyov
disolovyov / TypeClass.hs
Created October 11, 2012 14:51 — forked from tonymorris/TypeClass.hs
Type-class hierarchy
{-# LANGUAGE NoImplicitPrelude, MultiParamTypeClasses, Rank2Types, TypeOperators #-}
newtype Id a =
Id a
data a :\/ b =
Left a
| Right b
data a :/\ b =
@disolovyov
disolovyov / canvas.hs
Created August 21, 2012 19:29
Panda Canvas 2 prototyping...
import Control.Monad.Writer
import Data.IORef
import Data.List.Zipper (Zipper(..))
import qualified Data.List.Zipper as Zipper
import Graphics.Rendering.OpenGL hiding (flush)
import Graphics.UI.GLUT hiding (flush)
data CanvasAction = PointAction GLfloat GLfloat | FlushAction
type Canvas = Writer [CanvasAction] ()
@disolovyov
disolovyov / read_fallback.hs
Created August 5, 2012 09:15
Read from strings with a fallback on error
{-# LANGUAGE ScopedTypeVariables #-}
fromStr :: Read a => a -> String -> a
fromStr fallback s =
let parsed = reads s :: Read a => [(a, String)]
in case parsed of
[(result, _)] -> result
_ -> fallback
p :: Show a => a -> IO ()
@disolovyov
disolovyov / output.txt
Created July 12, 2012 06:01
Coding Dojo 2012-07-11
+
+
+ +
+
+
+ +
+ +
+ +
@disolovyov
disolovyov / fp_recursion.md
Created May 23, 2012 19:13
FP: Recursion - Homework

Recursion

Getting recursion involves trying recusion. Make your own implementations of standard Haskell functions you've seen and used before, namely: minimum, reverse, sum, product, take, drop, repeat, and cycle.

You can add an apostrophe suffix to the names of your versions of these functions to avoid naming conflicts. E.g. take becomes take'.

Try to implement as many as possible.

@disolovyov
disolovyov / wanted.md
Created March 12, 2012 13:09
Lonely startup developers seeking programming partners

Hi, we are Livesheets, a startup based in London and Riga. We need an extra hand, so we're looking for additions to the team.

That's where you come in.

Livesheets is about building a brand new (patent pending) way of creating, sharing, and selling calculations. Our application enables casual users to turn a simple formula into an interactive mathematical model, play with its parts in real time, and visualize the result with style.

@disolovyov
disolovyov / .gitattributes
Created November 14, 2011 23:28
Объектно-ориентированное программирование. Лабораторная работа 3.
*.zip -crlf -diff