Skip to content

Instantly share code, notes, and snippets.

View littlebenlittle's full-sized avatar
👋
Looking for gigs

Ben Little littlebenlittle

👋
Looking for gigs
View GitHub Profile
module _ where
data _≡_ {A : Set} : A → A → Set where
refl : ∀ (x : A) → x ≡ x
data GroupAxioms {A : Set} (id : A) (inv : A → A) (op : A → A → A) : Set where
GroupAxioms! :
∀ (x : A) → op x id ≡ x
→ ∀ (x : A) → op id x ≡ x
→ ∀ (x : A) → op x (inv x) ≡ id
#|(
Match against an infinite family of <!before> patterns
)
say 'x_x___x________' ~~ /
[
| 'x'
| '_' <!before [
| $
| '_' <?before $>
module _ where
-- Constructive Set
data CSet {A : Set} : (A → Set) → Set where
⟨_⟩ : (p : A → Set) → CSet p
data _∈_ {A : Set} {p : A → Set} (x : A) (S : CSet p) : Set where
∈-pf : p x → x ∈ S
### Keybase proof
I hereby claim:
* I am littlebenlittle on github.
* I am benlittle (https://keybase.io/benlittle) on keybase.
* I have a public key ASCMAixeMyR_wrla6Qsd_zlEme2cSl2AS-tm94lew4APlAo
To claim this, I am signing this object:
#| Generate a 5 word phrase. NOT crypto random.
'/usr/share/dict/cracklib-small'.IO.lines».lc.pick(5).join(' ').say;
@littlebenlittle
littlebenlittle / peano.pl
Last active May 16, 2020 16:51
Peanos Axioms for the natural numbers in just a few lines of prolog
zero.
nat(zero).
nat(X) :-
nat(Y),
suc(Y,X).
one.
suc(zero,one).
===RUNNING zef --debug install
install OUT:
install ERR:
Usage:
zef [--fetch] [--build] [--test] [--depends] [--test-depends] [--build-depends] [--force] [--force-resolve] [--force-fetch] [--force-extract] [--force-build] [--force-test] [--force-install] [--timeout=<Int>] [--fetch-timeout=<Int>] [--extract-timeout=<Int>] [--build-timeout=<Int>] [--test-timeout=<Int>] [--install-timeout=<Int>] [--degree=<Int>] [--fetch-degree=<Int>] [--test-degree=<Int>] [--dry] [--upgrade] [--deps-only] [--serial] [--contained] [--update=<Any>] [--exclude=<Any>] [--to|--install-to=<Any>] install [<wants> ...] -- Install
===RUNNING zef --debug uninstall
uninstall OUT:
use v6;
my @sub-commands = «
install
uninstall
test
fetch
build
look
update
@littlebenlittle
littlebenlittle / proto-tokens.raku
Last active March 7, 2020 18:00
How can the proto token match the B sym rather than the A sym?
use v6;
grammar Test {
token TOP { <x>+ % \h+ $<rest>=(.*) }
proto token x {*}
token x:sym<A> { \S+ [\h \S+]* }
token x:sym<B> {
"[" <special-token> "]" <.ws> <important-message>
}
token special-token { "SPECIAL TOKEN" }
@littlebenlittle
littlebenlittle / Tabular.raku
Created March 6, 2020 01:08
Basic tabular value parsing
# based on https://stackoverflow.com/a/60512071/5530704
module Tabular {
grammar Data {
token TOP {
<header-row> \n
<value-row>+ %% \n
}
token header-row { <.ws>+ %% <symbol> }