aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/target/jvm/index.lux
blob: 42c0e4c15043bad017630bcd5977ee65f788528d (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 "*"
   [abstract
    ["[0]" equivalence {"+" Equivalence}]]
   [data
    [format
     [binary {"+" Writer}]]]
   [type
    [primitive "*"]]]]
 ["[0]" // "_"
  [encoding
   ["[1][0]" unsigned {"+" 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)))
    (# equivalence.functor each
       ..value
       //unsigned.equivalence))

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