aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/target/jvm/index.lux
blob: 22f4645e322f00b3e61dedf4fbd3e03a1c71a078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(.using
 [library
  [lux (.except)
   [abstract
    ["[0]" equivalence (.only Equivalence)]]
   [data
    [format
     [binary (.only Writer)]]]
   [type
    [primitive (.except)]]]]
 ["[0]" //
  [encoding
   ["[1][0]" unsigned (.only U2)]]])

(def: .public length
  //unsigned.bytes/2)

(primitive: .public (Index kind)
  U2

  (def: .public index
    (All (_ kind) (-> U2 (Index kind)))
    (|>> abstraction))

  (def: .public value
    (-> (Index Any) U2)
    (|>> representation))

  (def: .public equivalence
    (All (_ kind) (Equivalence (Index kind)))
    (at equivalence.functor each
        ..value
        //unsigned.equivalence))

  (def: .public writer
    (All (_ kind) (Writer (Index kind)))
    (|>> representation //unsigned.writer/2))
  )