Skip to content

Commit

Permalink
finish impl of termInfo', revert some changes to PactSerialise
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoeldner committed Nov 29, 2023
1 parent d071ca2 commit d52ae3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions pact-core/Pact/Core/IR/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,12 @@ termInfo' f = \case
Conditional o i ->
Conditional <$> traverse (termInfo' f) o <*> f i
ListLit l i -> ListLit <$> traverse (termInfo' f) l <*> f i
Try e1 e2 i -> undefined -- Try e1 e2 <$> f i
Nullary term i ->
undefined -- Nullary term <$> f i
CapabilityForm cf i -> undefined -- CapabilityForm cf <$> f i
Try e1 e2 i -> Try <$> termInfo' f e1 <*> termInfo' f e2 <*> f i
Nullary term i -> Nullary <$> termInfo' f term <*> f i
CapabilityForm cf i -> CapabilityForm <$> traverse (termInfo' f) cf <*> f i
Error t i -> Error t <$> f i
ObjectLit m i -> undefined -- ObjectLit m <$> f i
ObjectLit m i -> ObjectLit <$> (traverse ._2) (termInfo' f) m <*> f i

instance Plated (Term name ty builtin info) where
plate f = \case
Var n i -> pure (Var n i)
Expand Down
9 changes: 4 additions & 5 deletions pact-core/Pact/Core/Serialise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Control.Applicative ((<|>))
import Pact.Core.Builtin
import Pact.Core.Persistence
import Pact.Core.Guards
import Pact.Core.Info (SpanInfo)
import Pact.Core.Names
import Pact.Core.Namespace
import Pact.Core.DefPacts.Types
Expand Down Expand Up @@ -72,13 +71,13 @@ data PactSerialise b i
, _decodeRowData :: ByteString -> Maybe (Document RowData)
}

serialisePact :: PactSerialise RawBuiltin SpanInfo
serialisePact :: PactSerialise RawBuiltin ()
serialisePact = PactSerialise
{ _encodeModuleData = docEncode V1.encodeModuleData . V1.stripSpanInfo
{ _encodeModuleData = docEncode V1.encodeModuleData
, _decodeModuleData = \bs ->
LegacyDocument . V1.addDefaultSpanInfo <$> LegacyPact.decodeModuleData bs
LegacyDocument <$> LegacyPact.decodeModuleData bs
<|> docDecode bs (\case
V1_CBOR -> fmap V1.addDefaultSpanInfo . V1.decodeModuleData
V1_CBOR -> V1.decodeModuleData
)

, _encodeKeySet = docEncode V1.encodeKeySet
Expand Down

0 comments on commit d52ae3d

Please sign in to comment.