Skip to content

Instantly share code, notes, and snippets.

View Sub.cs
using System;
abstract class TySub<A, B>
{
public abstract B Cast(A a);
}
class TySub_Refl<A, B> : TySub<A, B>
where A : B
{
View hk.py
from abc import ABCMeta
from abc import abstractmethod
from dataclasses import dataclass
from typing import Any
from typing import Callable
from typing import Generic
from typing import Optional
from typing import TypeVar
from typing import cast
View Nat.cs
#nullable enable
using System;
// ---
interface Hk<W, A> { }
// ---
View ParserClass.java
package example.playground.parserclass;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.experimental.Delegate;
import java.util.function.BiFunction;
import java.util.function.Function;
View PatternFail.hs
import Control.Exception
import System.IO.Unsafe
match :: (a -> b) -> a -> Maybe b
match m a = unsafeDupablePerformIO $
handle (\(PatternMatchFail _) -> pure Nothing) $ do
x <- evaluate (m a)
return (Just x)
what :: Either a b -> Maybe b
View Symbolic.hs
{-# LANGUAGE RankNTypes #-}
module Symbolic where
data Expr
= Var -- x
| Lit Double
| BinOp BinOp Expr Expr
| UnaOp UnaOp Expr
deriving (Show, Eq)
View ParserClass.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
View UFuture.java
package example.playground.ufuture;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import java.util.concurrent.CompletableFuture;
View MicroWire.java
package example.playground;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.With;
import java.lang.reflect.Constructor;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.Arrays;
View Parsec.java
package example.playground.parsec;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.val;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;