use it in pyright: playground link
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
| type nil = Nil | |
| (* This version is unsafe because it makes the assumption that index >= 0. *) | |
| let rec get_unsafe : 'a. at:int -> from:'a list -> 'a | nil = | |
| fun ~at:index ~from:list -> | |
| match list with | |
| | [] -> Nil | |
| | first :: _ when index = 0 -> first | |
| | _ :: rest -> get_unsafe ~at:(index - 1) ~from:rest |
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
| (* -*- Interfaces -*- *) | |
| module type ORDERED = sig | |
| type ('a, 'b) t | |
| end | |
| module type LINEAR = sig | |
| include ORDERED | |
| val exchange : 'a 'b. ('a, 'b) t -> ('b, 'a) t |
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 enum | |
| import typing | |
| class Nat(enum.Enum): | |
| O = enum.auto() | |
| S = enum.auto() | |
| type nat = typing.Literal[Nat.O] | tuple[typing.Literal[Nat.S], nat] | |
| O = Nat.O |
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
| module Util = struct | |
| let ( let*? ) = Option.bind | |
| let ( let*! ) = Result.bind | |
| let ( let@ ) = ( @@ ) | |
| let ( *> ) f g x = g (f x) | |
| let curry = ( @@ ) | |
| let curry2 f a b = f (a, b) | |
| let curry3 f a b c = f (a, b, c) | |
| let ( let|> ) a k = a (curry k) | |
| let ( let||> ) a k = a (curry2 k) |
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
| type left = private Left_tag | |
| type right = private Right_tag | |
| type ('ctr, 'left, 'right) t = | |
| | Left : 'a 'b. 'a -> (left, 'a, 'b) t | |
| | Right : 'a 'b. 'b -> (right, 'a, 'b) t | |
| let introduction_left : type a b. a -> (left, a, b) t = | |
| fun a -> Left a |
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
| e ::= x | |
| | '(' e ')' | |
| | e e | |
| | 'λ' x '.' e | |
| --------------------------------------------------------------- | |
| _&>_ a b = a ∧ (a → b) | |
| or_elim = (a → c) → (b → c) → a ∨ b → c | |
| or_elim f _ (Left a) = f a | |
| or_elim _ g (Right b) = g b |
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
| {-# LANGUAGE AllowAmbiguousTypes #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE UndecidableSuperClasses #-} | |
| import Data.Kind | |
| class (c a, c b) => SafeCoercible (c :: Type -> Constraint) a b | c a -> b where | |
| safeCoerce :: a -> b | |
| instance SafeCoercible Num Int Float where |
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
| %%%%%%%%%%%%%%%%%%%%%%%% | |
| % the bug fix workflow % | |
| %%%%%%%%%%%%%%%%%%%%%%%% | |
| ========================= | |
| what does a bug fix have? | |
| ========================= | |
| -> a name that can be referenced | |
| -> a description to use in commit & release |
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
| module False = struct | |
| (** This empty type represents falsehood. No proof (term) of | |
| it exists. *) | |
| type t = | | |
| (** [ex_falso_quodlibet] states that if we have the proof of | |
| falsehood, then we can prove anything. *) | |
| let ex_falso_quodlibet : 'a. t -> 'a = function | |
| | _ -> . | |
| end |
NewerOlder