1- open import Agda.Builtin.Int
2- open import Data.Fin
1+ open import Data.Char.Base as C using (Char)
32import Data.String as S
4- open import Data.Char.Base as Char using (Char )
3+ open import Data.Fin using (Fin; toℕ; zero )
54open import Data.Integer using (+_; ∣_∣)
65
76open 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+
2429instance
25- HsTy-SlotUpkeep = autoHsType SlotUpkeep ⊣ onConstructors (S.concat ∘ (S.wordsByᵇ ( '-' Char.≈ᵇ_)))
30+ HsTy-SlotUpkeep = autoHsType SlotUpkeep ⊣ onConstructors dropDash
2631 Conv-SlotUpkeep = autoConvert SlotUpkeep
2732
2833record 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
7373record 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
126120open import Class.Computational as C
0 commit comments