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 { do_ } from "@/utility"; | |
type Newtype<R extends object, S extends keyof R, T> = R[S] extends void | |
? R & T | |
: never; | |
const X1: unique symbol = Symbol(); | |
type X1 = Newtype<{ [X1]: void }, typeof X1, number>; | |
const X2: unique symbol = Symbol(); |
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
const serve_dir = "docs" | |
const port = 8000; | |
Bun.serve({ | |
port, | |
async fetch(req) { | |
const url_str = req.url.endsWith("/") ? `${req.url}index.html` : req.url | |
const url = new URL(url_str); | |
const filePath = `${serve_dir}${url.pathname}`; | |
console.log(`GET ${filePath}`) |
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
-- Solution 2: using breadth-first search | |
module Main where | |
import Prelude | |
import Data.Array as Array | |
import Data.Foldable (foldM, traverse_) | |
import Data.Traversable (traverse) | |
import Data.Tuple.Nested ((/\)) |
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 Control.Alternative (empty) | |
import Data.Generic.Rep (class Generic) | |
import Data.Map (Map) | |
import Data.Map as Map | |
import Data.Maybe (fromJust) | |
import Data.Show.Generic (genericShow) | |
import Effect (Effect) | |
import Effect.Class.Console as Console | |
import Effect.Ref as Ref | |
import Effect.Unsafe (unsafePerformEffect) |
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 Prelude | |
import Effect (Effect) | |
import Effect.Aff (launchAff_) | |
import Effect.Class (liftEffect) | |
import Effect.Class.Console as Console | |
import Node.Encoding (Encoding(..)) | |
import Node.EventEmitter (on_, once_) | |
import Node.FS.Sync as FS | |
import Node.HTTP (createServer) |
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 Main where | |
import Prelude | |
import Effect (Effect) | |
import Effect.Aff.Class (class MonadAff) | |
import Halogen as H | |
import Halogen.Aff as HA | |
import Halogen.HTML as HH | |
import Halogen.VDom.Driver as HVD |
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
// while iterating, have a `mut bindings: Vec<Bindings>` | |
// have a structure of Scopes that contain references to values in `bindings` | |
// a Binding doesn't refer to a Scope | |
// at the end, return `bindings`, so Scopes cannot own anything in bindings | |
// mutable reference is a subtype of immutable reference | |
fn example<'source>( | |
bindings: &mut Vec<Box<Binding<'source>>>, | |
names: Vec<&'source str>, | |
) { |
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 Languages.IntrinsicallyTypedLambdaCalculus where | |
import Prelude hiding (($), type (~>)) | |
import Data.Symbol (class IsSymbol) | |
import Prim.Row (class Cons) | |
import Type.Proxy (Proxy(..)) | |
-- ============================================================================= |
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 idea of this implementation is that a row (`Row`) serves as the | |
specification of either: | |
- a record (`Record<T extends Row>`) which is an object that, for each of the | |
elements of the row, has a key-value mapping from the element's tag to the | |
element's domain | |
- a variant (`Variant<T extends Row>`) which is a union of the row elements. | |
*/ | |
type Tuple = any[] |
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 Data.MyExistsConstrained where | |
import Prelude | |
import Unsafe.Coerce (unsafeCoerce) | |
-- Suppose you want to use an existentially-quantified type. You can use the | |
-- `exists` package, which defines `Exists` likes so: | |
foreign import data Exists :: (Type -> Type) -> Type |
NewerOlder