Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to purescript 0.10 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rintcius
Copy link

  • upgrade to purescript 0.10
  • some changes in package.json (split into build and test scripts & removed doc generation which is usually not expected from libs any more)

@@ -60,14 +59,15 @@ instance functorTree :: Functor Tree where
map f (Tree a ts) = Tree (f a) (map f <$> ts)

instance applyTree :: Apply Tree where
apply (Tree f tf) t@(Tree a ta) = Tree (f a) (map (f <$>) ta <> map (<*> t) tf)
apply (Tree f tf) t@(Tree a ta) = Tree (f a) (map (map f) ta <> map (applyFlipped t) tf)
where applyFlipped x y = apply y x
Copy link
Author

Choose a reason for hiding this comment

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

Couldn't find applyFlipped in standard libs

Copy link
Author

Choose a reason for hiding this comment

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

Updated now - thanks @LiamGoodacre for pointing out the use of operator sections

go n = do
sz <- Int.floor <<< Math.abs <$> arbitrary
Tree <$> arbitrary <*> replicateM sz (go (n / (sz + 1)))

replicateM n m | n < 1 = pure []
| otherwise = sequence $ replicate n m
Copy link
Author

Choose a reason for hiding this comment

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

Couldn't find replicateM in standard libs any more

Choose a reason for hiding this comment

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

I think you should be able to just do sequence (replicate sz (go (n / (sz + 1))). The replicate function for arrays will already deal with sz < 1. Alternatively there is replicateA from unfoldable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants