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

pipe map operator #469

Closed
maninalift opened this issue Feb 26, 2014 · 4 comments
Closed

pipe map operator #469

maninalift opened this issue Feb 26, 2014 · 4 comments

Comments

@maninalift
Copy link

I seem to specialize in reporting feature requests that I find interesting but even I am not entirely convinced by.

In this case it's the idea of vector pipes, AKA |> map. I like the idea of being able to represent this action with a single operator. :> fits because it looks like |> and : looks a bit like an array of little dots (cute).

When we want to pipe we will soon want to flatten so we can extend this syntax so that .> means |> concat-map and .:> means |> (concat-map . map) etcetera.

So that for example x .:..:> f means map f over the 5-deep array x, flattening the top three and bottom two levels together

e.g.

   x =
     * * * * <[a b c]>
           * <[d e f]>
         * * <[g h i]>
             <[j k l]>
       * * * <[m n o]>
         * * <[p q r]>
         * * <[s t u]>
     * * * * <[v w x]>
           * <[y z]>

   x .:..:> (.to-upper-case!)
 # = [["A","B","C","D","E","F","G","H","I","J","K","L"],["M","N","O","P","Q","R","S","T","U"],["V","W","X"],["Y","Z"]]

I don't think that there are that many places in people's code involving 5-deep arrays but the syntax pleases me so I thought I would suggest it.

Finally. You could add a | to make the syntax more robust to ambiguity: |:>, |.:>, and so on. With this addition it is easier to safely add more to the syntax such as mapping over objects without being too greedy with the syntax-space.

@vendethiel
Copy link
Contributor

ref satyr/coco#187

@robotlolita
Copy link
Contributor

Coco definitely seems to be on-par with Perl in terms of syntax.

What's wrong with flatten <| traverse (.to-upper-case!), xs? (Given an implementation of traverse as in http://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Traversable.html)

@vendethiel
Copy link
Contributor

One of coco's principle is "Perl over Ruby.", so it makes sense.
I agree there's no need for it, though

@vendethiel
Copy link
Contributor

Remembered #319

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

No branches or pull requests

3 participants