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 DataKinds, GADTs, KindSignatures, TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Data.HList | |
( HList(..) | |
, TypeMap | |
) where | |
import Data.Kind (Type) | |
import Data.Maybe (fromJust, fromMaybe) |
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
base26 :: Integer -> String | |
base26 n = | |
let (m, n') = n `divMod` 26 | |
ones = [toEnum (fromEnum 'A' + fromInteger n')] | |
in case m of | |
0 -> ones | |
m -> base26 (m - 1) ++ ones |
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 <stdio.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
typedef struct node { | |
int value; | |
struct node *next; | |
} node, *list; | |
void list_free(list l) |
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
use "collections" | |
interface Sendable | |
fun tag send(word: I64) | |
primitive Running | |
primitive Blocked | |
primitive Halted | |
primitive IllegalInstruction |
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
abstract type meat | |
Beef | |
pub Lamb(age: int) |
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
fun iota_vec(n: int): vector<int> | |
vector-init(n, id) | |
fun oddity(n: int): exn vector<int> | |
var v := iota_vec(n) | |
for(0, n) fn(i) | |
v[i] := v[i] + 3 | |
v | |
fun space-oddity(n: int): exn vector<int> |
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
open type openvar | |
A | |
B | |
extend type openvar | |
C | |
fun do_it_try_it(v: openvar): console () | |
match v | |
A -> println("got an A") |
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 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
(* yeah, so, Eff doesn't actually support polymorphic effects *) | |
effect Save: string -> int | |
effect Load: string * int -> empty | |
let save name = perform (Save name) | |
let load name v = absurd (perform (Load (name, v))) | |
let savegames = handler | |
| effect (Save name) k -> |
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
effect QuickSave: int option | |
effect QuickLoad: int -> empty | |
let quicksave () = perform QuickSave | |
let quickload n = absurd (perform (QuickLoad n)) | |
let quicksaving = handler | |
| effect QuickSave k -> | |
let rec quickloading () = handler | |
| effect (QuickLoad n) _ -> |