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
| #include <memory> | |
| #include <print> | |
| #include <sstream> | |
| #include <string> | |
| #include <variant> | |
| template<class... Ts> | |
| struct overloaded : Ts... { using Ts::operator()...; }; | |
| auto format(auto&& value) { |
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 Data.Ratio | |
| rat f g r = f (numerator r) % g (denominator r) | |
| num f = rat f id | |
| den f = rat id f | |
| -- fun way | |
| wallis = (2 % 1) : zipWith ($) (cycle [den (+2), num (+2)]) wallis |
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
| #include <assert.h> | |
| #include <stdarg.h> | |
| #include <stddef.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| // ============================================================== | |
| // # Utilities | |
| // ============================================================== |
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
| // === Library | |
| interface FeatureKey {} | |
| sealed interface LookupResult<S extends State<S, ?, ?>> { | |
| record Found<S extends State<S, ?, ?>>(S state) implements LookupResult<S> {} | |
| record NotFound<S extends State<S, ?, ?>>() implements LookupResult<S> {} | |
| } |
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
| data Dial = Dial Int deriving (Show, Eq) | |
| dialMod :: Num a => a | |
| dialMod = 100 | |
| instance Num Dial where | |
| (Dial x) + (Dial y) = Dial ((dialMod + x + y) `mod` dialMod) | |
| negate (Dial x) = Dial ((dialMod - x) `mod` dialMod) | |
| fromInteger x = Dial (fromInteger (x `mod` dialMod)) | |
| -- other Num methods skipped for brevity |
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
| package org.example; | |
| import static java.lang.reflect.AccessFlag.PUBLIC; | |
| import static java.lang.reflect.AccessFlag.STATIC; | |
| import static java.util.Objects.requireNonNull; | |
| import static java.util.function.Function.identity; | |
| import static org.example.Functions.curry; | |
| import static org.example.Functions.flip; | |
| import static org.example.TyEq.refl; | |
| import static org.example.TypeClass.Witness.Overlap.OVERLAPPABLE; |
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
| package org.example; | |
| import static java.lang.reflect.AccessFlag.PUBLIC; | |
| import static java.lang.reflect.AccessFlag.STATIC; | |
| import static java.util.Objects.requireNonNull; | |
| import static org.example.TypeClassSystem.witness; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.RetentionPolicy; | |
| import java.lang.reflect.Method; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| interface Refinement<T> { | |
| boolean isValid(T value); | |
| static <T, R1 extends Refinement<T>, R2 extends Refinement<T>> And<T, R1, R2> and(R1 r1, R2 r2) { | |
| return new And<>(r1, r2); | |
| } | |
| record And<T, R1 extends Refinement<T>, R2 extends Refinement<T>>(R1 r1, R2 r2) | |
| implements Refinement<T> { |
NewerOlder