How to use NonEmpty within a template
App Development2 posts164 views3 likesLast activity Apr 2022
CO
cohen.avrahamOP
Apr 2022G-d willing
Hello,
I want to use the NonEmpty for a list of Decimals within a template, and I can’t find a way in doing so.
When I am doing it on a regular data type it works okay, as follows:
let nums = NE.NonEmpty
with
hd = 2
tl = []
But when I am trying to do the same on a template I am getting an error.
template NonEmptyTest
with
sideA: Party
nums: NE.NonEmpty [Int]
where
signatory sideA
setup : Script ()
setup = script do
alice<- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
submit alice do
createCmd NonEmptyTest
with
sideA=alice
nums= NE.NonEmpty
with
hd = 2
tl = []
Can you please tell me what am I doing wrong?
CO
cocreature
Apr 2022Your template defines nums to be a non-empty list of lists of integers. However, you are trying to use it as a non-empty list of integers so without the extra level of lists.
Change the type to nums : NE.NonEmpty Int and it should work.