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 monad scheme | |
(require "curry.ss") | |
;; i'm too lazy to repeat this pattern for now. | |
(define-syntax init-public | |
(syntax-rules () | |
((_) (begin)) | |
((_ (m default) ms ...) (begin | |
(init-field (m default)) | |
(public (internal-m m)) | |
(define (internal-m . rest) (apply (get-field m this) rest)) |
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
import Control.Parallel.Strategies | |
data NF a = NF () a | |
nfBy :: Strategy a -> a -> NF a | |
nfBy s a0 = r where r@(NF _ a) = NF (s a) a0 | |
nf :: NFData a => a -> NF a | |
nf = nfBy rnf |
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
package scalaz | |
/** | |
* Defines a category. | |
* | |
* <p> | |
* All instances must satisfy 3 laws: | |
* <ol> | |
* <li><strong>left identity</strong><br/><code>∀ a. compose(id, a) == a</code></li> |
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
trait HomClass { self => | |
type L | |
type H>:L | |
type C[_>:L<:H,_>:L<:H] | |
type Dual <: HomClass { | |
type L=self.type#L | |
type H=self.type#H | |
type C[A>:L<:H,B>:L<:H] = self.type#C[B,A] | |
type Dual = self.type | |
} |
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
object hom { | |
trait set { | |
type inf | |
type sup >: inf | |
type hom[_>:inf<:sup,_>:inf<:sup] | |
type dual = set.of[inf,sup,({type λ[x>:inf<:sup,y>:inf<:sup]=hom[y,x]})#λ] | |
} | |
object set { | |
trait of[l,h>:l,c[_>:l<:h,_>:l<:h]] extends set { | |
type inf = l |
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> import magpie._ | |
import magpie._ | |
scala> type i = hom.set.singleton[Int] | |
defined type alias i | |
scala> type arr = hom.set.of[Nothing,Any,({type o[-x,+y] = y})#o, ({type f[-x,+y] = x => y })#f] | |
defined type alias arr | |
scala> (_/2) : arr#hom[Int,Double] |
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
package speculation | |
import java.util.concurrent.{ Callable, ExecutorService, Future } | |
class Speculation(val executor: ExecutorService, val mayInterruptIfRunning: Boolean) { | |
def spec[A,B](guess: => A)(f: A => B)(actual: => A): B = { | |
val g = executor.submit(new Callable[A] { | |
def call = guess | |
}) | |
val speculation = executor.submit(new Callable[B] { |
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 TypeFamilies, FlexibleContexts, TypeOperators, UndecidableInstances, GeneralizedNewtypeDeriving #-} | |
module Numeric.Vector.Space where | |
import Data.Functor.Representable.Trie hiding (Entry) | |
import Data.Key (Adjustable(..), Key) | |
import qualified Data.Key as Key | |
import qualified Data.Heap as Heap | |
import Data.Heap (Heap, Entry(..)) | |
import qualified Data.List.NonEmpty as NonEmpty | |
import Data.List.NonEmpty (NonEmpty(..)) |
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 Yield where | |
-- Cleaned up version of Yield: Mainstream Delimited Continuations by Roshan James and Amr Sabry from TPDC 2011 | |
import Data.Traversable | |
import Control.Monad.Trans | |
import Control.Monad.Free | |
import Control.Monad.Codensity | |
import Control.Comonad.Trans.Store |
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, FunctionalDependencies, FlexibleInstances, FlexibleContexts, UndecidableInstances #-} | |
module Numeric.Polynomial.Chebyshev where | |
import qualified Data.Map as Map | |
import Data.List (foldl') | |
zipWithT :: (a -> b -> c) -> ([a] -> [c]) -> ([b] -> [c]) -> [a] -> [b] -> [c] | |
zipWithT f fa fb = go where | |
go (a:as) (b:bs) = f a b : go as bs | |
go [] bs = fb bs |
OlderNewer