Polymorphism and Higher Order Functions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/12

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:35 PM on 3/20/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

13 Terms

1
New cards

Polymorphic List Definition

Inductive list (A : Type) : Type := nil : list A | cons : A -> list A -> list A. Lists parameterized by element type A, allowing reuse for any type.

2
New cards

map Function Type

map : forall (A B : Type), (A -> B) -> list A -> list B. Takes a function from A to B and a list of A, returns list of B. Higher-order and polymorphic.

3
New cards

Haskell Type Variables

Type variables a,b in signatures like map :: (a -> b) -> [a] -> [b] are prenex universally quantified: map : forall a b. (a -> b) -> [a] -> [b].

4
New cards

Haskell Type Constructor

[_] : Type -> Type (list type constructor). (->) : Type -> Type -> Type (function type constructor). Types themselves are first-class in type system.

5
New cards

Limitation of Haskell Types

Cannot directly type strange g = [g True, g 0] because g would need both Bool → ? and nat → ?. Requires impredicative polymorphism (g : forall A, A → B).

6
New cards

Rocq Strange Function Type

strange : forall (B : Type), (forall (A : Type), A -> B) -> list B. g must work for all argument types A, returning same result type B.

7
New cards

Dependent Types

vec_app : forall (n m : nat) (A : Type), Vec n A -> Vec m A -> Vec (n + m) A. Type depends on value (length n), enabling precise length specifications.

8
New cards

Rocq Type Hierarchy

0 : nat, nat : Set, Set : Type, Prop : Type, Type : Type (with universes to avoid paradoxes). Types themselves have types (sorts).

9
New cards

Rocq vs Haskell Types

Rocq types are terms with t : τ relation. Supports arbitrary quantification, dependent types, while Haskell types are prenex polymorphic only.

10
New cards

Termination in Rocq

Rocq's λ-calculus (Calculus of Inductive Constructions) is terminating, ensuring all functions are total and proofs are consistent.

11
New cards

Polymorphic Map Implementation

Fixpoint map (A B : Type) (f : A -> B) (l : list A) : list B := match l with | nil _ => nil B | cons _ x xs => cons B (f x) (map A B f xs) end. Explicit type arguments.

12
New cards

System F

Haskell's core type system (System F) supports parametric polymorphism with prenex universal quantification. Basis for polymorphic programming.

13
New cards

λ-cube (Barendregt)

Framework classifying type systems by three axes: polymorphism (types depending on types), dependent types (types depending on terms), and operators (terms depending on types). Rocq near the top

Explore top notes

note
Native Americans
Updated 1190d ago
0.0(0)
note
Atomic Structure
Updated 1035d ago
0.0(0)
note
AP Government Unit 1
Updated 574d ago
0.0(0)
note
UDHR Complete Summary Notes
Updated 1268d ago
0.0(0)
note
WHAP Unit 0, 4, 5
Updated 216d ago
0.0(0)
note
Synaptic Transfer
Updated 1305d ago
0.0(0)
note
Native Americans
Updated 1190d ago
0.0(0)
note
Atomic Structure
Updated 1035d ago
0.0(0)
note
AP Government Unit 1
Updated 574d ago
0.0(0)
note
UDHR Complete Summary Notes
Updated 1268d ago
0.0(0)
note
WHAP Unit 0, 4, 5
Updated 216d ago
0.0(0)
note
Synaptic Transfer
Updated 1305d ago
0.0(0)