Darklang

1 program Added 2026-02-26T10:00:00Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled Evidence Report issue View issues
Aliases: Dark
Provenance: commit 8c4cc37c48 · authored 2026-02-26T18:27:45+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

2 sources · pl_id: pl/darklang
LLM (this repo) · 1Pldb

Related languages

Dark (0.71)Dart (0.33)nklang (0.29)D (0.24)D2 (0.22)

LLM-contributed programs

Stdlib List Operations

Provenance: commit 8c4cc37c48 · authored 2026-02-26T18:27:45+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
code.dark · license: MIT · added: 2026-02-26T10:00:00Z
module Darklang.Stdlib.List


/// Returns an empty list
let empty = []

/// Returns a one-element list containing the given <param val>
let singleton (value: 'a) : List<'a> =
  [ value ]


/// Returns {{Some}} the head (first value) of a list.
/// Returns {{None}} if the list is empty.
let head (list: List<'a>) : Option.Option<'a> =
  match list with
  | [] -> Option.Option.None
  | head :: _ -> Option.Option.Some head


/// If <param list> contains at least one value, returns {{Some}} with a list of
/// every value other than the first. Otherwise, returns {{None}}.
let tail (list: List<'a>) : Option.Option<List<'a>> =
  match list with
  | [] -> Option.Option.None
  | _ :: tail -> Option.Option.Some tail


/// Returns a new list with all values in <param as> followed by all values in <param bs>,
/// preserving the order
let append (as_: List<'a>) (bs: List<'a>) : List<'a> =
  Builtin.listAppend as_ bs


/// Add element <param value> to front of <type list> <param list>
let push (list: List<'a>) (value: 'a) : List<'a> =
  append [ value ] list


/// Add element <param val> to back of <type list> <param list>
let pushBack (list: List<'a>) (value: 'a) : List<'a> =
  append list [ value ]


/// Returns the last value in <param list>, wrapped in an option (<paramNone> if the list is empty)
let last (list: List<'a>) : Option.Option<'a> =
  match list with
  | [] -> Option.Option.None
  | head :: tail ->
    match tail with
    | [] -> Option.Option.Some head
    | _ -> last tail


// Todo: remove the helper function once we have recursive lambdas
let reverseHelper (list: List<'a>) (acc: List<'a>) : List<'a> =
  match list with
  | [] -> acc
  | head :: tail -> reverseHelper tail (push acc head)

/// Returns a reversed copy of <param list>
let reverse (list: List<'a>) : List<'a> = reverseHelper list []


/// Returns {{Some firstMatch}} where <var firstMatch> is the first value of the
/// list for which <param fn> returns {{true}}. Returns {{None}} if no such
/// value exists
let findFirst (list: List<'a>) (fn: 'a -> Bool) : Option.Option<'a> =
  match list with
  | [] -> Option.Option.None
  | head :: tail ->
    if (fn head) then
      Option.Option.Some head
    else
      findFirst tail fn


/// Returns {{true}} if <param value> is in the list
let ``member`` (list: List<'a>) (value: 'a) : Bool =
  Option.isSome (findFirst list (fun elem -> elem == value))

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about Darklang (mapped to pl/darklang). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Darklang/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← DarkBASIC Darmok →