Skip to content

Commit

Permalink
Fix #1296 String chunkBySize fails
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Dec 18, 2017
1 parent 5333b3d commit 58b2a3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/fable-core/Seq.ts
Expand Up @@ -464,7 +464,7 @@ export function map3<T1, T2, T3, U>(

export function chunkBySize<T>(size: number, xs: Iterable<T>): Iterable<Iterable<T>> {
const result = arrayChunkBySize(size, Array.from(xs));
return ofArray(result.map(ofArray));
return ofArray(result);
}

export function mapFold<T, ST, R>(
Expand Down
5 changes: 5 additions & 0 deletions tests/Main/StringTests.fs
Expand Up @@ -15,6 +15,11 @@ let ``String literal addition is optimized``() =
"bar" + aLiteral |> equal "barfoo"
"bar" + notALiteral |> equal "barfoo"

[<Test>]
let ``String chunkBySize works``() = // See #1296
"fffff" |> Seq.chunkBySize 3 |> Seq.map String |> Seq.toList
|> equal ["fff"; "ff"]

// Format

[<Test>]
Expand Down

4 comments on commit 58b2a3f

@vasily-kirichenko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I'm curious, the Seq.ts, was it written by hand or generated?

@alfonsogarciacaro
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to you for reporting! Do you need a release very quickly or can you do it with the workaround for now?

About the files in fable-core, I originally wrote them in JS mainly by translating the modules in FunScript.Core manually. Then another contributor translated them to TypeScript and we've been tweaking the files since then. Though some have been actually compiled with Fable (Map, Set and BigInteger) with some manual tweaks (mostly to export functions independently to help tree shaking by JS bundlers). I've also the idea of adding Fable compilation to fable-core build so we can add modules in F# directly in the future, but I haven't implemented it yet (shouldn't be difficult with fable-splitter now).

@vasily-kirichenko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, a new release is not an emergency, thanks :)

@vasily-kirichenko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

Please sign in to comment.