Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,323
    • Issues 4,323
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 361
    • Merge Requests 361
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18927

Closed
Open
Opened Nov 05, 2020 by Sebastian Graf@sgraf812Developer

Use `SmallArray#`

I think there are several places in the compiler where lists are the wrong data structure and we are better off using an array, e.g. when storing something for multiple uses, never changing it afterwards.

We have SmallArray# in GHC.Exts and we should use it. The problem is that the only half-way comfortable API I know of is in primitive, which isn't a boot package. And even that wrapper is far from a feature-complete API to be usable as a drop-in replacement for lists; I think it's merely a compatibility wrapper offering the same API for GHC < 7.10, where it's backed by an Array# (plus it uses MonadPrim instead).

So I propose to add our own module GHC.Data.SmallVec that offers a few key pure functions for a persistent API around SmallArray#. I hope for the following instances:

  • A fusing IsList instance
  • Functor+Foldable+Traversable (maybe even Applicative) instance
  • an indexing function
  • (Binary+Outputable instance)

That should do.

Ideas where to use SmallVec (feel free to add more):

  • Product Demands
  • Syntax elements, such as MatchGroups
  • (basically everything which is a syntax-dependent list and thus constant in length by construction)
Edited Nov 10, 2020 by Sebastian Graf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18927