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
""" | |
Quadtree in Numba: | |
Notes: | |
1. `if field:` or `if not field:` for an optional field | |
type doesn't work in numba, instead do `if field is not None:` or | |
`if field is None:`. | |
2. There is a bug with numba code generation with assignment | |
to deferred types. To work around that, add `set_field` methods | |
in the @jitclass (like `set_top_left_tree`) and use those inside a @njit |
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
structure Lam = | |
struct | |
datatype bop = Add | Sub | Mul | |
val showBop = fn Add => "Add" | Sub => "Sub" | Mul => "Mul" | |
datatype exp = Lit of int | Bop of bop * exp * exp | Call of string * exp list | |
type var = string | |
val showVar = fn t0 => "\"" ^ t0 ^ "\"" |
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 <stdio.h> | |
enum bop { | |
BOP_PLUS, | |
BOP_MINUS, | |
BOP_TIMES, | |
}; | |
typedef struct ast_exp ast_exp; |
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
{-# OPTIONS_GHC -Wno-orphans #-} | |
module SoundEager where | |
import Bluefin.Compound (Handle, mapHandle, useImpl, useImplIn) | |
import Bluefin.Eff (Eff, Effects, runPureEff, (:&), (:>)) | |
import Bluefin.Internal (StateSource (StateSource)) | |
import Bluefin.State (State, evalState, get, modify, put) | |
import Bluefin.StateSource (newState, withStateSource) | |
import Data.Functor ((<&>)) |
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
from __future__ import annotations # type: ignore | |
from typing import * # type: ignore | |
from dataclasses import dataclass, field | |
@dataclass | |
class Physical: | |
register: int | |
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
#!/bin/bash | |
cat > build.smi <<EOL | |
_require "basis.smi" | |
_require "smlnj-lib.smi" | |
EOL | |
cat > build.sml <<EOL | |
signature PACK_REAL = sig | |
type real |
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
-- You need DeepSubsumption enabled in order for the example to compile. | |
{-# LANGUAGE DeepSubsumption #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Eval where | |
import Control.Monad.State.Strict (StateT, evalStateT, gets, liftIO, modify', void) | |
import Data.Comp.Multi |
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
infix & +` *` | |
datatype ('a, 'b) stmt = | |
Assign of 'a * ('a, 'b) expr | |
| If of ('a, 'b) expr * ('b, 'a) stmt list * ('a, 'b) stmt list | |
and ('a, 'b) expr = | |
Stmt of ('a, 'a) stmt | |
| Int of 'b | |
| Bop of ('b, 'a) expr * ('a, 'b) expr |
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
ann "milletDiagnosticsIgnore all" in | |
./mltonlib/com/ssh/extended-basis/unstable/basis.mlb | |
./mltonlib/com/ssh/generic/unstable/lib.mlb | |
./mltonlib/com/ssh/generic/unstable/with/generic.sml | |
./mltonlib/com/ssh/generic/unstable/with/eq.sml | |
./mltonlib/com/ssh/generic/unstable/with/type-hash.sml | |
./mltonlib/com/ssh/generic/unstable/with/type-info.sml | |
./mltonlib/com/ssh/generic/unstable/with/hash.sml | |
./mltonlib/com/ssh/generic/unstable/with/uniplate.sml | |
./mltonlib/com/ssh/generic/unstable/with/ord.sml |
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
structure Fold = | |
struct | |
fun fold (a, f) g = g (a, f) | |
fun post (w, g) s = | |
w (fn (a, h) => s (a, g o h)) | |
fun step0 h (a, f) = | |
fold (h a, f) | |
fun step1 h (a, f) b = | |
fold (h (b, a), f) |
NewerOlder