I'm trying to convert the following C# code to F#.
static async Task<IEnumerable<string>> ListingObjectsAsync()
{
ListObjectsV2Request request = new ListObjectsV2Request
{
BucketName = bucketName,
MaxKeys = 10
};
ListObjectsV2Response response;
do
{
response = await client.ListObjectsV2Async(request);
foreach (S3Object entry in response.S3Objects)
{
yield return entry.Key;
}
request.ContinuationToken = response.NextContinuationToken;
} while (response.IsTruncated);
}
However, the following unfinished code got the error of
Error FS0795 The use of 'let! x = coll' in sequence expressions is not permitted. Use 'for x in coll' instead.
let listObjects bucketName = async {
use client = new AmazonS3Client(RegionEndpoint.USEast2)
let request = new ListObjectsRequest(BucketName = bucketName, MaxKeys = 10)
// do while... todo
seq {
let! response = client.ListObjectsV2Async(request) |> Async.AwaitTask
for entry in response.S3Objects do
yield entry.Key
request.ContinuationToken <- response.NextContinuationToken
}
How to convert the C# do {...} while(...); to F# btw?