@@ -163,7 +163,9 @@ printOtherCase iTyDefs otherCase = do
163163 bodyDoc <- printValueE iTyDefs $ otherCase arg
164164 return $ group $ argDoc <+> " =>" <+> bodyDoc
165165
166- --- | `printCaseIntE i [(1, x), (2,y)] (\other -> z)` translates into `LambdaBuffers.Runtime.Plutus.LamValcaseIntE i [(1,x), (2,y)] (\other -> z)`
166+ --- | Call `case_int` function `lbr_prelude`
167+ --
168+ -- `printCaseIntE i [(1, x), (2,y)] (\other -> z)` translates into `lbr_prelude::prelude::case_int(i, vec![(1, x), (2,y)]), Box::new(move |other| z)`
167169printCaseIntE :: MonadPrint m => PC. TyDefs -> LV. ValueE -> [(LV. ValueE , LV. ValueE )] -> (LV. ValueE -> LV. ValueE ) -> m (Doc ann )
168170printCaseIntE iTyDefs caseIntVal cases otherCase = do
169171 caseIntERefDoc <- R. printRsQValName <$> LV. importValue RR. caseIntERef
@@ -180,11 +182,21 @@ printCaseIntE iTyDefs caseIntVal cases otherCase = do
180182 otherDoc <- printLamE iTyDefs otherCase
181183 return $ group $ caseIntERefDoc <> encloseSep lparen rparen comma [caseValDoc, align (R. printRsQValName RR. vecMacro <> encloseSep lbracket rbracket comma caseDocs), otherDoc]
182184
185+ {- | Print a list of values
186+ ```
187+ [<A>, <B>]
188+ ```
189+ -}
183190printListE :: MonadPrint m => PC. TyDefs -> [LV. ValueE ] -> m (Doc ann )
184191printListE iTyDefs vals = do
185192 valDocs <- printValueE iTyDefs `traverse` vals
186193 return $ brackets (align (encloseSep mempty mempty (comma <> space) valDocs))
187194
195+ {- | Print a list (Vector in Rust) construction using vec! macro
196+ ```
197+ std::vec![<A>, <B>]
198+ ```
199+ -}
188200printNewListE :: MonadPrint m => PC. TyDefs -> [LV. ValueE ] -> m (Doc ann )
189201printNewListE iTyDefs vals = do
190202 lst <- printListE iTyDefs vals
@@ -306,6 +318,19 @@ printCaseTextE iTyDefs txtVal cases otherCase = do
306318 otherDoc <- printOtherCase iTyDefs otherCase
307319 return $ " ma" <> align (" tch" <+> caseValDoc <+> braces (line <> vsep (punctuate comma (caseDocs <> [otherDoc]))))
308320
321+ {- | Print a reference
322+
323+ To help Rust type inference, we inject type information for a few references.
324+ In case of a `toPlutusData`, `fromPlutusData`, `toJson`, `fromJson` we call the reference as a trait
325+ method on the target type:
326+ ```rs
327+ <TargetType>::to_plutus_data(...)
328+ ```
329+ In case of `jsonConstructor`, we print the target type in a turbofish syntax:
330+ ```rs
331+ lbr_prelude::json::json_constructr::<TargetType>::toPlutusData(...)
332+ ```
333+ -}
309334printRefE :: MonadPrint m => LV. Ref -> m (Doc ann )
310335printRefE ref = do
311336 qvn <- LV. resolveRef ref
0 commit comments