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 TypeFamilies, DeriveFunctor, DeriveFoldable, DeriveTraversable #-} | |
| import Control.Applicative {- from base -} | |
| import Data.Distributive {- from distributive -} | |
| import Data.Key {- from the keys package -} | |
| import Data.Functor.Bind {- from semigroupoids -} | |
| import Data.Functor.Representable {- from representable-functors -} | |
| -- lets define unpacked affine 3-vectors of doubles | |
| data Vector = Vector {-# UNPACK #-} !Double {-# UNPACK #-} !Double {-# UNPACK #-} !Double deriving (Eq, Ord, Show) |
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
| import Control.Applicative | |
| import Control.Monad (MonadPlus(..), guard) | |
| import Data.Char (isDigit, digitToInt, isSpace) | |
| import Data.Foldable | |
| import Data.Traversable | |
| import Data.Monoid | |
| -- a parsec-like packrat parser | |
| data Result d 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 NPlusKPatterns, RankNTypes #-} | |
| -- ransacking infinite structures quickly without side-effects | |
| import Data.Maybe (fromMaybe) | |
| import Control.Applicative | |
| import Data.Map (Map) | |
| import qualified Data.Map as Map | |
| import Control.Monad | |
| import Control.Monad.Trans.Class |
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 Data.Tree.Braun | |
| ( Tree | |
| , replicate | |
| , fromList | |
| , singleton | |
| , null | |
| , empty | |
| , twist | |
| -- * Sanity check | |
| , braun |
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 GADTs, Rank2Types, KindSignatures, ScopedTypeVariables, TypeOperators, DataKinds, PolyKinds, MultiParamTypeClasses, FlexibleInstances, TypeFamilies, DoRec, ExtendedDefaultRules #-} | |
| import Control.Applicative | |
| import Control.Category | |
| import Control.Comonad | |
| import Control.Monad.Fix | |
| import Control.Monad (ap) | |
| import Data.Functor.Identity | |
| import Data.Typeable | |
| import Data.Monoid | |
| import Data.Unique |
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
| import Text.Printf | |
| import Data.List | |
| import System.CPUTime.Rdtsc | |
| import Control.Seq | |
| import Data.Bits | |
| data Shape = Shape00 | Shape01 | Shape02 | Shape03 | Shape04 | Shape05 | Shape06 | Shape07 | Shape08 | Shape09 | |
| | Shape10 | Shape11 | Shape12 | Shape13 | Shape14 | Shape15 | Shape16 | Shape17 | Shape18 | Shape19 | |
| | Shape20 | Shape21 | Shape22 | Shape23 | Shape24 | Shape25 | Shape26 | Shape27 | Shape28 | Shape29 | |
| | Shape30 | Shape31 | Shape32 | Shape33 | Shape34 | Shape35 | Shape36 | Shape37 | Shape38 | Shape39 |
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
| -- e | |
| > let z a b c d w@(x:y)=let t=a`div`c in if all(>0)[a,b,c,d]&&t==b`div`d then t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show | |
| > let z a b c d w@(x:y)|t<-a`div`c=if all(>0)[a,b,c,d]&&t==b`div`d then t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show | |
| > let z a b c d w@(x:y)|all(>0)[a,b,c,d]&&t==b`div`d|True=t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y where t=a`div`c;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show | |
| > let z a b c d w@(x:y)|all(>0)[a,b,c,d]&&t==b`div`d=t:z(10*(a-c*t))(10*(b-d*t))c d w|True=z(x*a+b)a(x*c+d)c y where{t=a`div`c};f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show | |
| > let f n=1:1:n:f(n+2);z a b c d w@(x:y)|t<-a`div`c,all(>0)[a,b,c,d]&&t==b`div`d=t:z(10*(a-c*t))(10*(b-d*t))c d w|True=z(x*a+b)a(x*c+d)c y in z 1 0 0 1(2:1:2:f 4)>>=show | |
| > let f n=1:1:n:f(n+2);z a b c d w@(x:y)|any(<=0)[a,b,c,d]||t/=b`div`d=z(x*a+b)a(x*c+d)c y|t<-a`div`c=t:z(10*(a-c*t))(10*(b-d*t))c d w |
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 CPP #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704 | |
| {-# LANGUAGE Trustworthy #-} |
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 GADTs #-} | |
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE DeriveDataTypeable #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| module Isos where | |
| import Control.Applicative | |
| import Unsafe.Coerce |
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 GADTs #-} | |
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| import Control.Applicative | |
| import Control.Arrow | |
| import Control.Category |