44{-# LANGUAGE DefaultSignatures #-}
55{-# LANGUAGE FlexibleContexts #-}
66{-# LANGUAGE FlexibleInstances #-}
7+ {-# LANGUAGE GADTs #-}
78{-# LANGUAGE MultiParamTypeClasses #-}
89{-# LANGUAGE OverloadedStrings #-}
910{-# LANGUAGE PolyKinds #-}
2728module Cardano.Ledger.Core (
2829 -- * Transaction types
2930 TxType (.. ),
31+ STxType (.. ),
3032 withTxType ,
3133 applyTxType ,
3234 applyFullTxType ,
@@ -144,11 +146,11 @@ type data TxType = FullTx | SubTx
144146
145147withTxType ::
146148 forall f t a era . Typeable t => f t era -> (f FullTx era -> a ) -> (f SubTx era -> a ) -> a
147- withTxType txType withFullTxType withSubTxType =
149+ withTxType anyTxType withFullTxType withSubTxType =
148150 case eqT @ t @ FullTx of
149- Just Refl -> withFullTxType txType
151+ Just Refl -> withFullTxType anyTxType
150152 Nothing -> case eqT @ t @ SubTx of
151- Just Refl -> withSubTxType txType
153+ Just Refl -> withSubTxType anyTxType
152154 Nothing -> error $ " Impossible: Unrecognized TxType: " <> show (typeRep (Proxy @ t ))
153155
154156applyTxType ::
@@ -168,6 +170,10 @@ applyFullTxType decFullTx =
168170 fail $
169171 " SubTx type is not supported for " <> show (typeRep (Proxy @ f ))
170172
173+ data STxType t where
174+ SFullTx :: STxType FullTx
175+ SSubTx :: STxType SubTx
176+
171177-- | A transaction.
172178class
173179 ( EraTxBody era
@@ -186,6 +192,8 @@ class
186192 where
187193 data Tx (t :: TxType ) era
188194
195+ txType :: Tx t era -> STxType t
196+
189197 mkBasicTx :: Typeable t => TxBody t era -> Tx t era
190198
191199 bodyTxL :: Lens' (Tx t era ) (TxBody t era )
@@ -238,6 +246,8 @@ class
238246 -- | The body of a transaction.
239247 data TxBody (t :: TxType ) era
240248
249+ txBodyType :: TxBody t era -> STxType t
250+
241251 mkBasicTxBody :: TxBody FullTx era
242252
243253 inputsTxBodyL :: Lens' (TxBody t era ) (Set TxIn )
0 commit comments