This file contains 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
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module HFilter where | |
data a :* b = a :* b | |
deriving (Show, Eq) | |
infixr 5 :* | |
hlist :: Int :* String :* Int :* Maybe Float :* () |
This file contains 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 Chainable ( | |
(==.), (.==.), (.==), | |
(/=.), (./=.), (./=), | |
(<.), (.<.), (.<), | |
(>.), (.>.), (.>), | |
(<=.), (.<=.), (.<=), | |
(>=.), (.>=.), (.>=), | |
) where | |
-- start Eq chain |
This file contains 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
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} | |
module Chainable ( | |
(==?), (/=?), | |
(<?), (<=?), (>?), (>=?), | |
isJust | |
) where | |
import Data.Maybe (isJust) | |
import Control.Monad (liftM, liftM2) |
This file contains 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
{-# LANGUAGE TypeOperators #-} | |
-- inspired by "Why concatenative programming matters." | |
-- (http://evincarofautumn.blogspot.com/2012/02/why-concatenative-programming-matters.html) | |
-- | |
-- playing with adapting row polymorphism to Haskell, because, hey, why not? | |
module RowPolymorphism.Primitives ( | |
(:>)(), Stack, | |
lift, quote, (!), | |
dip, dup, over, swap, drop, call | |
) where |
This file contains 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
Insert 13 | |
10 | |
/ \ | |
5 15 | |
/ \ | |
11 20 | |
\ | |
13 |
This file contains 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
scala> def k( j : (Int => Int) => Int ) : Int = j(_+1) | |
k: (j: Int => Int => Int)Int | |
scala> def p(q : Int => Int) : Int = q(0) | |
p: (q: Int => Int)Int | |
scala> def z = (x : Int) => (y : Int) => x + y | |
z: Int => Int => Int | |
scala> k(p) |
This file contains 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
abstract class SemiGroup[A] { | |
def add(x: A, y: A): A | |
} | |
abstract class Monoid[A] extends SemiGroup[A] { | |
def unit: A | |
} | |
object ImplicitTest extends App { | |
def sum[A](xs: List[A])(implicit m: Monoid[A]): A = | |
if (xs.isEmpty) m.unit |
This file contains 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 Palindrome where | |
-- an adaptation of Johan Jeuring's algorithm for finding maximal palindrome lengths | |
-- (http://johanjeuring.blogspot.com/2007/08/finding-palindromes.html) | |
import Control.Arrow ((***)) | |
-- find the maximal lengths of the palindromes | |
-- centered before, on, and after each element in the list | |
maximalPalindromeLengths :: Eq a => [a] -> [Int] | |
maximalPalindromeLengths as = grow 0 [] as as [] |
This file contains 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
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> | |
<script> | |
jQuery(function($){ | |
var draw = function(shape){ | |
var a = 50; | |
var b = a*shape[0]; | |
var c = a*shape[1]; |
This file contains 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
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> | |
<script> | |
jQuery(function($){ | |
var draw = function(shape){ | |
var a = 50; | |
var b = a*shape[0]; | |
var c = a*shape[1]; |