Skip to content

Instantly share code, notes, and snippets.

@techtangents
techtangents / Nel.hs
Created January 24, 2013 12:21
Just learning how to instance Comonad on Non-Empty List
module Nel where
import Control.Comonad
infixr 5 :|
data Nel a = a :| [a]
toList :: Nel a -> [a]
toList (a :| as) = a : as
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
import Data.Distributive
class (Functor a, Functor b) => Bidistributive a b where
dist :: a (b c) -> b (a c)
tsid :: b (a c) -> a (b c)
instance (Distributive x, Distributive y) => Bidistributive x y where
dist = distribute
@techtangents
techtangents / fundipitive.hs
Created December 21, 2012 11:21
Fundiptive
infixl 4 -*-, -$-
class Fundipitive f where
(-*-) :: f (a -> b) -> f a -> f b
(-$-) :: (a -> b) -> f a -> f b
liftFd2 ::
Fundipitive f =>
(a -> b -> r)
-> f a
type Stepper v = StepperImpl v s
data StepperImpl v s = StepperImpl {
initial :: s,
next :: s -> (v -> s -> StepState v s) -> StepState v s -> StepState v s
}
data StepState v s = More v s | Done
step1 :: StepperImpl v s -> StepState v s
@techtangents
techtangents / gist:4137760
Created November 23, 2012 23:57
Thesaurus
return
loggedUnit("Initializing thesaurus from file: " + zipFile)
.anonBindStrict(setLicense())
.anonBind(loadFromZipF(zipFile))
.appendLogIfNone("Unable to intialise Thesaurus.");