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
{ stdenv, fetchFromGitHub, haskell, haskellPackages }: | |
with haskell.lib; | |
let hie-src = stdenv.mkDerivation { | |
name = "haskell-ide-engine"; | |
src = fetchFromGitHub { | |
owner = "haskell"; | |
repo = "haskell-ide-engine"; | |
rev = "cb600ac290d91a0fc967487fa17a83f9f58fe3d6"; | |
sha256 = "1xhq1y2dbjiqn3i9gk5a2lv0iyjlkiv9r1xm99ampv2j9aksn6fj"; |
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 Criterion | |
import Criterion.Main | |
import HSTrav | |
import Data.List | |
import qualified Data.Sequence as Seq | |
main :: IO () | |
main = defaultMain | |
[ bench "heap-sort" (nf sortTraversable [1000000,999999 .. 1 :: Int]) |
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 ConstraintKinds #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} |
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
@FunctionalInterface | |
public interface FunctionX<X extends Throwable, T, R> { | |
R apply(T t) throws X; | |
default <V> FunctionX<X, V, R> compose(FunctionX<? extends X, ? super V, ? extends T> before) { | |
Objects.requireNonNull(before); | |
return (V v) -> apply(before.apply(v)); | |
} | |
default <V> FunctionX<X, T, V> andThen(FunctionX<? extends X, ? super R, ? extends V> after) { | |
Objects.requireNonNull(after); | |
return (T t) -> after.apply(apply(t)); |
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
public interface SupplierX<X extends Throwable, T> { | |
T get() throws X; | |
} |
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
public interface PredicateX<X extends Throwable, T> { | |
boolean test(T t) throws X; | |
default PredicateX<X, T> and(PredicateX<? extends X, ? super T> other) { | |
Objects.requireNonNull(other); | |
return (t) -> test(t) && other.test(t); | |
} | |
default PredicateX<X, T> negate() { | |
return (t) -> !test(t); |
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
@FunctionalInterface | |
public interface ConsumerX<X extends Throwable, T> { | |
void accept(T t) throws X; | |
default ConsumerX<X, T> andThen(ConsumerX<? extends X, ? super T> after) { | |
Objects.requireNonNull(after); | |
return (T t) -> { accept(t); after.accept(t); }; | |
} | |
} |
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
public final class OptionalX<T> { | |
private static final OptionalX<?> EMPTY = new OptionalX<>(); | |
private final T value; | |
private OptionalX() { | |
this.value = null; | |
} | |
public static<T> OptionalX<T> empty() { |
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
data Some1 = Some1 { name :: String } | Some1' | |
data Some2 = Some2 { name :: Int } | Some2' | |
-- Would be generated | |
name :: some <: Some1 + Some2 - { Some1', Some2' } -> { | |
case s of | |
Some1 name = name | |
Some2 name = name | |
| s <- some | |
} |
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
index :: l <: [a] - ([]) -> i <: { n <- Int | n < length l; n >= 0 } -> { -- notice the shortcutting, | |
-- using the l type as an argument to length instead | |
-- of having to bind l to a name as a foreach. | |
case (l, i) of -- similar shortcutting | |
(x:xs, 0) = x | |
(x:xs, n) = index xs (n - 1) | |
} |