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 RankNTypes #-} | |
module Scheduling where | |
newtype Fiber f a = Fiber (f (Maybe (Maybe a, Fiber f a))) | |
noop :: Applicative f => Fiber f a | |
noop = Fiber $ pure Nothing | |
singleton :: Applicative f => f (Maybe a) -> Fiber f a |
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
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <functional> | |
#include <optional> | |
#include <variant> | |
#include <any> | |
template<template<typename, typename> typename CP, typename A, typename B, typename R, template<typename> typename F> concept Coproduct2 = | |
requires (CP<A,B> cp, F<R(A)> f, F<R(B)> g) { |
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
static interface CommutativeSemigroup<A> extends Semigroup<A> { | |
} | |
static interface CommutativeMonoid<A> extends CommutativeSemigroup<A>, Monoid<A> { | |
} | |
static interface Abelian<A> extends CommutativeMonoid<A> { | |
A inverse(A a); | |
} | |
static interface Ring<A> { | |
Abelian<A> addition(); | |
Monoid<A> multiplication(); |
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
#include <thread> | |
#include <iostream> | |
#include <functional> | |
#include <algorithm> | |
#include <numeric> | |
#include <any> | |
namespace { | |
struct __ {}; | |
struct ___ {}; |
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
#include <thread> | |
#include <iostream> | |
#include <functional> | |
template<typename T> using Id = T&; | |
template<typename A, typename B> | |
struct Phi { | |
template<typename R> | |
R match(std::function<R(A)>, std::function<R(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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>mnichols</groupId> | |
<artifactId>lambda-spike</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>lambda-spike</name> | |
<description>examples</description> |
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 com.jnape.palatable.lambda.adt.hlist; | |
import com.jnape.palatable.lambda.adt.hlist.HList.HCons; | |
import com.jnape.palatable.lambda.adt.hlist.HList.HNil; | |
import java.util.function.Function; | |
import static com.jnape.palatable.lambda.adt.hlist.HList.cons; | |
import static com.jnape.palatable.lambda.adt.hlist.HList.nil; | |
import static com.jnape.palatable.lambda.adt.hlist.HList.singletonHList; |
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 example; | |
import com.jnape.palatable.lambda.functions.builtin.fn2.Cons; | |
import com.jnape.palatable.lambda.functions.builtin.fn2.Snoc; | |
import java.util.Iterator; | |
import static com.jnape.palatable.lambda.functions.builtin.fn3.FoldLeft.foldLeft; | |
import static example.SizedIterable.Nat.s; | |
import static example.SizedIterable.Nat.stringify; |
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 spike; | |
import com.jnape.palatable.lambda.adt.choice.Choice2; | |
import com.jnape.palatable.lambda.adt.coproduct.CoProduct2; | |
import com.jnape.palatable.lambda.functions.Fn1; | |
import com.jnape.palatable.lambda.functions.Fn2; | |
import com.jnape.palatable.lambda.functions.builtin.fn2.Cons; | |
import com.jnape.palatable.lambda.functor.Bifunctor; | |
import java.util.Iterator; |
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 static class SetIsNotAFullyFaithfulFunctor { | |
public static void main(String[] args) { | |
class Mod { | |
private final int mod; | |
private final int value; | |
Mod(int mod, int value) { | |
this.mod = mod; | |
this.value = value; | |
} |
NewerOlder