This file contains hidden or 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
return | |
loggedUnit("Initializing thesaurus from file: " + zipFile) | |
.anonBindStrict(setLicense()) | |
.anonBind(loadFromZipF(zipFile)) | |
.appendLogIfNone("Unable to intialise Thesaurus."); |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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 #-} | |
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 |
This file contains hidden or 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 Nel where | |
import Control.Comonad | |
infixr 5 :| | |
data Nel a = a :| [a] | |
toList :: Nel a -> [a] | |
toList (a :| as) = a : as |
This file contains hidden or 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 NoImplicitPrelude, TypeOperators #-} | |
import Prelude(undefined, Either(..), either, Functor(..)) | |
data Store a b = | |
Store (a -> b) a | |
instance Functor (Store a) where | |
fmap f (Store p g) = | |
Store (f . p) g |
This file contains hidden or 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
const x _ = x | |
counter = counter' 0 | |
counter' n = | |
foldp' (\_ s -> s + 1) (const n) |
This file contains hidden or 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
-- non-empty list | |
data NonEmpty x = NonEmpty x [x] | |
-- neFromList :: [x] -> NonEmpty x | |
neFromList list = case list of [] -> Maybe.Nothing | |
(x:xs) -> Maybe.Just (NonEmpty x xs) | |
-- neFromListOr :: NonEmpty x -> [x] -> NonEmpty x | |
neFromListOr other qs = maybeOr other (neFromList xs) |
This file contains hidden or 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
Absolutely: | |
- any integer | |
- Incorrect - any integer except Integer.MIN_VALUE | |
Bytes: | |
- on each line, the numbers [0..128], [-127..-1] | |
- Incorrect - infinite loop | |
Constants: | |
- characters on lines: STUVWXYZ |
This file contains hidden or 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
{- | |
Recall that function composition is: | |
f . g = f (g x) | |
Consider, (f . g) as the application of g to an parameter destined for f. | |
Let's decribe g as the 'mapper' function and f as the 'primary function' | |
This gist generalises this idea to primary functions of different arities (in curried form). | |
Each parameter to the primary function has its own mapper function. | |
The API forms a similar style to that of Applicative, where infix functions chain values together in an expression. |
OlderNewer