Skip to content

Towards unlifted HashMaps #463

Open
Open
@sjakobi

Description

@sjakobi

This compiles with GHC-9.4-alpha1:

{-# language UnliftedDatatypes, MagicHash #-}

module M where

import Data.Kind (Type)
import GHC.Exts

data Leaf k v :: UnliftedType where
  L :: !k -> v -> Leaf k v

type HashMap' :: Type -> Type -> UnliftedType
data HashMap' k v
    = Empty
    | BitmapIndexed !Word !(SmallArray# (HashMap' k v))
    | Leaf !Word !(Leaf k v)
    | Full !(SmallArray# (HashMap' k v))
    | Collision !Word !(SmallArray# (Leaf k v))

data HashMap k v = HM !(HashMap' k v)

If the ergonomics work out, maybe we could start using a similar representation around GHC 8.8.

The main benefit should be better performance due to the removal of heap checks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions