MyNixOS website logo
Description

a library to build and work with heterogeneous, type level indexed rose trees.

built with nix built on haskell ci haddock

htree: heterogeneous rose tree

This library implements a heterogeneous rose-tree (HTree) that is indexed by a type-level rosetree (TyTree).

It also offers some useful functions, highlights include:

  • searching in the tree and creating evidence on the term-level via typeclasses
  • record-dot syntax for accessing elements in the tree.
  • mapping and traversing trees

to develop

  • with direnv: direnv allow
  • only with nix: nix develop
  • to run all checks: nix flake check -Lv systems configurations
  • build with nix nix build (or on ghc96, nix build .#ghc96-htree)
  • documentation in the form of continuously deployed haddock can be found at mangoiv.srht.site

example

pattern I :: forall a. a -> Identity a
pattern I a = Identity a

-- the type that the tree is going to be indexed by
type Ex =
  TyNode Int
   [ TyNode Int
       [ TyNode Int '[]
       , TyNode Bool '[]
       , TyNode String '[ TyNode Int '[]]
       ]
    , TyNode Int '[]
    ]

-- we create an HTree of the example type 'Ex'
ex :: HTree Identity Ex
ex =
  HNode 5 do
    HNode 12 do
      HNode 13 HNil
        ::: HNode (I False) HNil
        ::: HNode "test" (HNode 9 HNil ::: HNil)
        ::: HNil
      ::: HNode 43 HNil
      ::: HNil
    

-- we can create a labeled Tree and search via DFS and BFS in it
-- the search happens on the type-level
type LabeledTree = TyNodeL "top" Int
  [ TyNodeL "inter" Int '[ TyNodeL "foo" Int '[] ]
  , TyNodeL "foo" Int '[]
  ]

-- >>> getElem @'DFS @"foo" @Int Proxy labeledTree
-- Identity 69
-- >>> getElem @'BFS @"foo" @Int Proxy labeledTree
-- Identity 67
labeledTree :: HTree Identity LabeledTree
labeledTree = 42 `HNodeL` HNodeL 4 (HNodeL 69 HNil ::: HNil) ::: HNodeL 67 HNil ::: HNil
Metadata

Version

0.1.1.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows