@@ -9,43 +9,9 @@ import Data.HVect
99import  Fathom.Base
1010import  Fathom.Data.Sing
1111import  Fathom.Format.Record
12- --  import Fathom.Format.InductiveRecursiveCustom
1312
1413
15- namespace Format . Pairs 
16- 
17-   |||  Construct a format based on a type tag
18-   value  :  Nat  ->  Format
19-   value 1  =  u8
20-   value 2  =  u16Be
21-   value 4  =  u32Be
22-   value _  =  fail 
23- 
24- 
25-   |||  A heterogeneous sequence of values where the element formats depend on a
26-   |||  sequence of type tags
27-   values  :  (ts  : Vect  len Nat ) ->  Format
28-   values [] =  pure () 
29-   values (t ::  ts) =  pair (value t) (values ts)
30- 
31- 
32-   |||  An annoying example from: https://github.com/yeslogic/fathom/issues/394
33-   ouch  :  Format
34-   ouch =  do 
35-     len <-  u16Be
36-     types <-  repeat  len u16Be
37-     values <-  values types
38-     pure () 
39- 
40- 
41-   |||  Access an element at index @i of the in-memory representation of @values.
42-   |||  The type of the returned element is dependent on the sequence of type tags.
43-   index  :  {ts  : Vect  len Nat } ->  (i  : Fin  len) ->  (values ts).Rep ->  (value (index i ts)).Rep
44-   index {ts =  _  ::  _ } FZ  (x, _ ) =  x
45-   index {ts =  _  ::  _ } (FS  i) (_ , xs) =  Format . index i xs
46- 
47- 
48- namespace Format . HRepeat 
14+ namespace Format 
4915
5016  |||  Construct a format based on a type tag
5117  value  :  Nat  ->  Format
@@ -60,6 +26,6 @@ namespace Format.HRepeat
6026  ouch =  do 
6127    len <-  u16Be
6228    types <-  repeat  len u16Be
63-     values <-  hrepeat  (map  value types)
64-     --         ^^^^^^^  heterogeneous repetitions 
29+     values <-  tuple  (map  value types)
30+     --         ^^^^^ heterogeneous sequence of formats 
6531    pure () 
0 commit comments