aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/target/jvm/index.lux
blob: 2ac48514b4198be18a79f8cee192a9cea4f4d0bc (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
39
(.require
 [library
  [lux (.except)
   [abstract
    ["[0]" equivalence (.only Equivalence)]]
   [data
    [binary
     [\\format (.only Format)]]]
   [meta
    [type
     ["[0]" primitive (.except def)]]]]]
 ["[0]" //
  [encoding
   ["[1][0]" unsigned (.only U2)]]])

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

(primitive.def .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 format
    (All (_ kind) (Format (Index kind)))
    (|>> representation //unsigned.format/2))
  )