Skip to content

Commit d2c43e6

Browse files
committed
Formatting
1 parent e996a44 commit d2c43e6

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

formal-spec/Leios/Foreign/Export.agda

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
open import Agda.Builtin.Int
2-
open import Data.Fin
1+
open import Data.Char.Base as C using (Char)
32
import Data.String as S
4-
open import Data.Char.Base as Char using (Char)
3+
open import Data.Fin using (Fin; toℕ; zero)
54
open import Data.Integer using (+_; ∣_∣)
65

76
open import Class.Convertible
@@ -21,13 +20,19 @@ module Leios.Foreign.Export where
2120
{-# LANGUAGE DuplicateRecordFields #-}
2221
#-}
2322

23+
dropDash : S.String S.String
24+
dropDash = S.concat ∘ (S.wordsByᵇ ('-' C.≈ᵇ_))
25+
26+
prefix : S.String S.String S.String
27+
prefix p = p S.++_
28+
2429
instance
25-
HsTy-SlotUpkeep = autoHsType SlotUpkeep ⊣ onConstructors (S.concat ∘ (S.wordsByᵇ ('-' Char.≈ᵇ_)))
30+
HsTy-SlotUpkeep = autoHsType SlotUpkeep ⊣ onConstructors dropDash
2631
Conv-SlotUpkeep = autoConvert SlotUpkeep
2732

2833
record IBHeader : Type where
29-
field slotNumber : Int
30-
producerID : Int
34+
field slotNumber :
35+
producerID :
3136
bodyHash : String
3237

3338
{-# FOREIGN GHC
@@ -41,15 +46,10 @@ instance
4146
HsTy-IBHeader = MkHsType IBHeaderAgda IBHeader
4247
Conv-IBHeader : Convertible IBHeaderAgda IBHeader
4348
Conv-IBHeader = record
44-
{ to = λ (record { slotNumber = sl ; producerID = pid ; bodyHash = h }) record { slotNumber = + sl ; producerID = + toℕ pid ; bodyHash = h}
49+
{ to = λ (record { slotNumber = sl ; producerID = pid ; bodyHash = h })
50+
record { slotNumber = + sl ; producerID = + toℕ pid ; bodyHash = h}
4551
; from = λ (record { slotNumber = sl ; producerID = pid ; bodyHash = h })
46-
record
47-
{ slotNumber = ∣ sl ∣
48-
; producerID = zero
49-
; lotteryPf = tt
50-
; bodyHash = h
51-
; signature = tt
52-
}
52+
record { slotNumber = ∣ sl ∣ ; producerID = zero ; lotteryPf = tt ; bodyHash = h ; signature = tt }
5353
}
5454

5555
HsTy-IBBody = autoHsType IBBody
@@ -71,8 +71,8 @@ instance
7171
Conv-ℕ = Convertible-Refl
7272

7373
record EndorserBlock : Type where
74-
field slotNumber : Int
75-
producerID : Int
74+
field slotNumber :
75+
producerID :
7676
ibRefs : List String
7777

7878
{-# FOREIGN GHC
@@ -89,16 +89,10 @@ instance
8989
Conv-EndorserBlock : Convertible EndorserBlockAgda EndorserBlock
9090
Conv-EndorserBlock =
9191
record
92-
{ to = λ (record { slotNumber = sl ; producerID = pid ; ibRefs = refs }) record { slotNumber = + sl ; producerID = + toℕ pid ; ibRefs = refs }
92+
{ to = λ (record { slotNumber = sl ; producerID = pid ; ibRefs = refs })
93+
record { slotNumber = + sl ; producerID = + toℕ pid ; ibRefs = refs }
9394
; from = λ (record { slotNumber = sl ; producerID = pid ; ibRefs = refs })
94-
record
95-
{ slotNumber = ∣ sl ∣
96-
; producerID = zero
97-
; ibRefs = refs
98-
; ebRefs = []
99-
; lotteryPf = tt
100-
; signature = tt
101-
}
95+
record { slotNumber = ∣ sl ∣ ; producerID = zero ; ibRefs = refs ; ebRefs = [] ; lotteryPf = tt ; signature = tt }
10296
}
10397

10498
Listable-Fin : Listable (Fin 1)
@@ -117,10 +111,10 @@ instance
117111
HsTy-LeiosState = autoHsType LeiosState
118112
Conv-LeiosState = autoConvert LeiosState
119113

120-
HsTy-LeiosInput = autoHsType LeiosInput ⊣ onConstructors (("I_" S.++_) ∘ S.concat ∘ (S.wordsByᵇ ('-' Char.≈ᵇ_)))
114+
HsTy-LeiosInput = autoHsType LeiosInput ⊣ onConstructors (prefix "I_" ∘ dropDash)
121115
Conv-LeiosInput = autoConvert LeiosInput
122116

123-
HsTy-LeiosOutput = autoHsType LeiosOutput ⊣ onConstructors (("O_" S.++_) ∘ S.concat ∘ (S.wordsByᵇ ('-' Char.≈ᵇ_)))
117+
HsTy-LeiosOutput = autoHsType LeiosOutput ⊣ onConstructors (prefix "O_" ∘ dropDash)
124118
Conv-LeiosOutput = autoConvert LeiosOutput
125119

126120
open import Class.Computational as C

0 commit comments

Comments
 (0)