Skip to content

Commit

Permalink
Rearrange Tree.bind parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Becker authored and adam-becker committed Feb 2, 2021
1 parent c553aca commit 00e45b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Hedgehog/Gen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Gen =
let run (seed : Seed) (random : Random<'x>) : 'x =
Random.run seed size random

Tree.bind (run seed1 m) (run seed2 << k))
Tree.bind (k >> run seed2) (run seed1 m))

let bind (k : 'a -> Gen<'b>) (m : Gen<'a>) : Gen<'b> =
toRandom m |> bindRandom (toRandom << k) |> ofRandom
Expand Down
6 changes: 3 additions & 3 deletions src/Hedgehog/Tree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ module Tree =
let rec map (f : 'a -> 'b) (Node (x, xs) : Tree<'a>) : Tree<'b> =
Node (f x, Seq.map (map f) xs)

let rec bind (Node (x, xs0) : Tree<'a>) (k : 'a -> Tree<'b>) : Tree<'b> =
let rec bind (k : 'a -> Tree<'b>) (Node (x, xs0) : Tree<'a>) : Tree<'b> =
match k x with
| Node (y, ys) ->
let xs = Seq.map (fun m -> bind m k) xs0
let xs = Seq.map (bind k) xs0
Node (y, Seq.append xs ys)

let join (xss : Tree<Tree<'a>>) : Tree<'a> =
bind xss id
bind id xss

/// Turns a tree, in to a tree of trees. Useful for testing Hedgehog itself as
/// it allows you to observe the shrinks for a value inside a property,
Expand Down

0 comments on commit 00e45b7

Please sign in to comment.