MFPS 2026 – Agda Code
List
Initializing search
    pdmosses/mfps2026-agda
    • About
    • Notation
    • Examples
    • Properties
    • Tests
    • Library
    pdmosses/mfps2026-agda
    • About
      • Abstract
      • Background
        • Denotational-Semantics
        • Agda
      • Meta-notation
    • Notation
      • Domains
      • Flat
        • Booleans
        • Naturals
      • Functions
      • Products
        • Sequences
        • Tuples
      • Recursion
      • Sums
      • Updates
    • Examples
      • LC
        • Abstract-Syntax
        • Domain-Equations
        • Semantic-Functions
      • PCF
        • Abstract-Syntax
        • Domain-Equations
        • Semantic-Functions
      • Scm
        • Abstract-Syntax
        • Auxiliary-Functions
        • Domain-Equations
        • Semantic-Functions
    • Properties
      • Flat
        • Booleans
        • Naturals
      • Functions
      • Products
        • Sequences
        • Tuples
      • Recursion
      • Sums
      • Updates
    • Tests
      • LC
      • PCF
    • Library
          • Bool
          • Char
            • Properties
          • Equality
            • Rewrite
          • Int
          • List
          • Maybe
          • Nat
          • Sigma
          • String
            • Properties
          • Unit
        • Primitive
      • Algebra
        • Bundles
          • Raw
          • Base
          • Propositional
          • Setoid
            • Base
            • MaxOp
            • MinMaxOp
            • MinOp
        • Core
        • Definitions
          • RawMagma
          • Bundles
            • Raw
              • MaxOp
              • MinMaxOp
              • MinOp
            • BooleanAlgebra
            • DistributiveLattice
            • Lattice
            • Semilattice
          • Structures
        • Morphism
          • Definitions
          • Structures
          • CommutativeSemigroup
          • Semigroup
        • Structures
          • Biased
          • Propositional
        • UniquenessOfIdentityProofs
          • Base
          • Properties
          • Base
          • Properties
        • Empty
          • Polymorphic
          • Base
          • Patterns
          • Properties
          • Base
        • Irrelevant
          • Base
            • Propositional
            • Setoid
            • Base
          • Properties
              • Lex
                • Core
                • Strict
              • Pointwise
                • Base
                • Properties
              • All
              • AllPairs
                • Core
              • Any
          • Base
              • Any
          • Base
          • Divisibility
            • Core
          • DivMod
            • Core
          • GeneralisedArithmetic
          • Induction
          • Properties
          • Base
          • Algebra
          • Base
          • Properties
              • All
          • Base
          • Base
          • Properties
        • Sum
          • Algebra
          • Base
          • Properties
          • Base
          • Base
          • Polymorphic
            • Base
            • Properties
          • Base
        • Applicative
        • Choice
        • Empty
        • Functor
        • Monad
        • Base
        • Bundles
        • Consequences
          • Propositional
          • Setoid
          • Composition
          • Identity
          • Symmetry
        • Core
        • Definitions
          • Bundles
              • Equality
          • Bundles
          • Core
          • Definitions
          • Nat
            • Bundles
            • Core
            • Definitions
            • Structures
          • Structures
          • Inverse
          • RightInverse
        • Structures
      • Induction
        • WellFounded
      • Level
          • Bundles
            • Raw
          • Consequences
              • Reflexive
                • Properties
            • Composition
              • Core
              • EqAndOrd
            • Intersection
              • Left
            • NonStrictToStrict
            • True
          • Core
          • Definitions
            • Heterogeneous
              • Bundles
                • Trivial
              • Core
              • Definitions
              • Structures
          • Lattice
            • Bundles
            • Definitions
            • Structures
            • Definitions
            • Structures
            • Poset
            • Preorder
            • Setoid
            • TotalOrder
          • PropositionalEquality
            • Algebra
            • Core
            • Properties
              • Double
              • Single
              • Triple
            • Preorder
            • Setoid
            • Syntax
          • Structures
            • Biased
        • Nullary
          • Decidable
            • Core
          • Irrelevant
          • Negation
            • Core
          • Recomputable
            • Core
          • Reflects
        • Unary
          • PredicateTransformer
          • Properties
    1. Library
    2. Agda
    3. Builtin

    List

    {-# OPTIONS --cubical-compatible --safe --no-sized-types --no-guardedness --level-universe #-}
    
    module Agda.Builtin.List where
    
    infixr 5 _∷_
    data List {a} (A : Set a) : Set a where
      []  : List A
      _∷_ : (x : A) (xs : List A) → List A
    
    {-# BUILTIN LIST List #-}
    
    {-# COMPILE JS  List = function(x,v) {
      if (x.length < 1) { return v["[]"](); } else { return v["_∷_"](x[0], x.slice(1)); }
    } #-}
    {-# COMPILE JS [] = Array() #-}
    {-# COMPILE JS _∷_ = function (x) { return function(y) { return Array(x).concat(y); }; } #-}
    
    Made with MaterialX