Skip to content

Instantly share code, notes, and snippets.

@m93a
Last active October 24, 2023 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m93a/1d618b664293bdd032680d25f3832fb7 to your computer and use it in GitHub Desktop.
Save m93a/1d618b664293bdd032680d25f3832fb7 to your computer and use it in GitHub Desktop.

Mag

Tired? Mag it! Down? Mag time! Liver damage? MAXIMUM MAG! You’re about to become a magnesium-based lifeform. The age of the primitive carbon-man is done.DE

Tier 1

These features are the core of Mag, and need to be implemented to make it usable.

Tier 2

These features are important and would make working with Mag much more pleasant.

Tier 3

These features are sexy af and would turn Mag into one of those languages CS students nerd out about.

  • Declarative-reactive data types (modeled after Svelte's components but more general) with automatic signal wrapping & unwrapping
  • Resumability (resume code on a different machine) and RPCs
  • Type refinements (like C#'s contracts or LiquidHaskell's type predicates)
  • Effects – a generalization of throw, await and yield (see the Effekt language)
  • Build to WASM
  • Some kind of DSLs, maybe wrapped in ` or ```
  • Pure and invertible functions for use in two-way data binding

Tier 4

These are random thoughts and ideas that might be cool to implement, but also maybe not.

  • Named parameters (kwargs)
  • Pipe operators, monadic operators
  • Block-level return (return from a block, not from a function)
  • Utf-8 strings with good utilities
  • Lazy evaluation
  • Trileans
  • Cancellable async function
  • Parametric modules, import stubs, import with

Syntax ideas

  • \ – anonymous type union, effects

  • |> – regular pipe, a |> b(%) === b(a)

  • .> – pointwise pipe, a .> b(%) === a.map(b)

  • :> – flatmap pipe, a :> b(%) === a.flatMap(b)

  • => – lambda function

  • -> – function type, let f: number -> number = x => 2 * x

  • > – block return

  • |> case – pattern-match over argument (map over type union), x |> case [1, n] => [n, 1]

  • |> handle – handle effect in argument, x |> handle Yield(n) => 2 * n

  • match, case, handle, rematch – recursive matching

  • do vs raise (there's conflict between Effekt's do and a JS proposal)

  • ? suffix for nullable-like types, for example number? for number \ NaN

Unsolved design problems

  • in TS it is impossible to do this: <T extends A | B>(x: T, y: T): A[] | B[] => [x, y] – both x and y can be a union, there is no way to force them to be concrete types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment