Skip to content

Commit 152fb8a

Browse files
committed
Forwar encode/decode functions via wrapper formats
1 parent acabfc1 commit 152fb8a

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

experiments/idris/src/Fathom/Closed/IndexedInductive.idr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ record Format where
9696
format : FormatOf Rep
9797
9898
99+
namespace Format
100+
101+
decode : (f : Format) -> Decode (Rep f, Colist a) (Colist a)
102+
decode f = FormatOf.decode f.format
103+
104+
105+
encode : (f : Format) -> Encode (Rep f) (Colist a)
106+
encode f = FormatOf.encode f.format
107+
108+
99109
------------------------------------
100110
-- FORMAT DESCRIPTION CONVERSIONS --
101111
------------------------------------

experiments/idris/src/Fathom/Closed/IndexedInductiveCustom.idr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace FormatOf
6262

6363

6464
export
65-
decode : {0 A : Type} -> (f : FormatOf A) -> Decode (A, ByteStream) (ByteStream)
65+
decode : {0 A : Type} -> (f : FormatOf A) -> Decode (A, ByteStream) ByteStream
6666
decode End [] = Just ((), [])
6767
decode End (_::_) = Nothing
6868
decode Fail _ = Nothing
@@ -85,7 +85,7 @@ namespace FormatOf
8585
8686
8787
export
88-
encode : {0 A : Type} -> (f : FormatOf A) -> Encode A (ByteStream)
88+
encode : {0 A : Type} -> (f : FormatOf A) -> Encode A ByteStream
8989
encode End () = Just []
9090
encode (Pure x) (MkSing _) = Just []
9191
encode (Skip f def) () = encode f def
@@ -112,6 +112,16 @@ record Format where
112112
format : FormatOf Rep
113113
114114
115+
namespace Format
116+
117+
decode : (f : Format) -> Decode (Rep f, ByteStream) ByteStream
118+
decode f = FormatOf.decode f.format
119+
120+
121+
encode : (f : Format) -> Encode (Rep f) ByteStream
122+
encode f = FormatOf.encode f.format
123+
124+
115125
------------------------------------
116126
-- FORMAT DESCRIPTION CONVERSIONS --
117127
------------------------------------

experiments/idris/src/Fathom/Closed/InductiveRecursive.idr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ data FormatOf : (A : Type) -> Type where
124124
MkFormatOf : (f : Format) -> FormatOf (Rep f)
125125
126126
127+
namespace FormatOf
128+
129+
decode : {0 A : Type} -> (f : FormatOf A) -> Decode (A, ByteStream) ByteStream
130+
decode (MkFormatOf f) = Format.decode f
131+
132+
133+
encode : {0 A : Type} -> (f : FormatOf A) -> Encode A ByteStream
134+
encode (MkFormatOf f) = Format.encode f
135+
136+
127137
------------------------------------
128138
-- FORMAT DESCRIPTION CONVERSIONS --
129139
------------------------------------

experiments/idris/src/Fathom/Closed/InductiveRecursiveCustom.idr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ data FormatOf : (Rep : Type) -> Type where
159159
MkFormatOf : (f : Format) -> FormatOf (Rep f)
160160
161161
162+
namespace FormatOf
163+
164+
decode : {0 A : Type} -> (f : FormatOf A) -> Decode (A, ByteStream) ByteStream
165+
decode (MkFormatOf f) = Format.decode f
166+
167+
168+
encode : {0 A : Type} -> (f : FormatOf A) -> Encode A ByteStream
169+
encode (MkFormatOf f) = Format.encode f
170+
171+
162172
------------------------------------
163173
-- FORMAT DESCRIPTION CONVERSIONS --
164174
------------------------------------

experiments/idris/src/Fathom/Open/Record.idr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ data FormatOf : (A : Type) -> Type where
182182
MkFormatOf : (f : Format) -> FormatOf f.Rep
183183
184184
185+
namespace FormatOf
186+
187+
decode : {0 A : Type} -> (f : FormatOf A) -> Decode (A, ByteStream) ByteStream
188+
decode (MkFormatOf f) = Format.decode f
189+
190+
191+
encode : {0 A : Type} -> (f : FormatOf A) -> Encode A ByteStream
192+
encode (MkFormatOf f) = Format.encode f
193+
194+
185195
------------------------------------
186196
-- FORMAT DESCRIPTION CONVERSIONS --
187197
------------------------------------

0 commit comments

Comments
 (0)