Re: Spec: Nested Cat Calls

2017-05-16 Thread Alex Miller
The problem here is that s/or is NOT a regex op and introduces a new level 
of spec nesting. Try using s/alt (which IS a regex op) instead.


On Tuesday, May 16, 2017 at 11:34:10 PM UTC-5, Alexander Sedgwick wrote:
>
> I'm looking to better understand how nested cats work (now that just 
> sounds funny).
>
> I've found that sometimes spec/cat will generate a nested list:
>
> ```clojure
> (gen/sample (s/gen (s/cat :start #{\a}
>   :content (s/cat :nothing (s/? #{\^})
> :fruit (s/or 
> :apples (s/+ (s/cat :skin #{\s}
>   
>  :flesh #{\f}
>   
>  :core #{\c}))
>   
>  :bananas (s/+ #{\b})))
>:end #{\z})) 5)
> ```
> -> ((\a \^ (\s \f \c) \z) ... (\a \^ (\b \b) \z))
>
> Given the sample output we can assume this validate call will be false 
> (provided flat list):
>
> ```clojure
> (s/valid? (s/cat :start #{\a}
>:content (s/cat :nothing (s/? #{\^})
>  :fruit (s/or :apples (s/+ 
> (s/cat :skin #{\s}
>   
>   :flesh #{\f}
>   
>   :core #{\c}))
> :bananas (s/+ 
> #{\b})))
>:end #{\z}) [\a \^ \s \f \c \z])
> ```
> -> false
>
> I thought the s/spec function would need to be used to define nested 
> structures (s/spec (s/cat ...)).
>
> Is this expected behavior or is there a better approach for working with 
> flat lists?
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Spec: Nested Cat Calls

2017-05-16 Thread Alexander Sedgwick
I'm looking to better understand how nested cats work (now that just sounds 
funny).

I've found that sometimes spec/cat will generate a nested list:

```clojure
(gen/sample (s/gen (s/cat :start #{\a}
  :content (s/cat :nothing (s/? #{\^})
:fruit (s/or 
:apples (s/+ (s/cat :skin #{\s}

   :flesh #{\f}

   :core #{\c}))
  
 :bananas (s/+ #{\b})))
   :end #{\z})) 5)
```
-> ((\a \^ (\s \f \c) \z) ... (\a \^ (\b \b) \z))

Given the sample output we can assume this validate call will be false 
(provided flat list):

```clojure
(s/valid? (s/cat :start #{\a}
   :content (s/cat :nothing (s/? #{\^})
 :fruit (s/or :apples (s/+ 
(s/cat :skin #{\s}

:flesh #{\f}

:core #{\c}))
:bananas (s/+ 
#{\b})))
   :end #{\z}) [\a \^ \s \f \c \z])
```
-> false

I thought the s/spec function would need to be used to define nested 
structures (s/spec (s/cat ...)).

Is this expected behavior or is there a better approach for working with 
flat lists?

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] specter-edn 0.1.2

2017-05-16 Thread Jason Felice
And, I forgot the link: https://github.com/maitria/specter-edn
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] specter-edn 0.1.2

2017-05-16 Thread Jason Felice
Thank you to Marcelo Nomoto for bug fixes and updating the dependencies!

specter-edn

Specter paths for working with formatted EDN and Cloure code.

There is one specter path: SEXPR. This navigates to a sequence of
s-expressions parsed from a string.

For the transform case, specter-edn preserves whitespace and comments using
a sort of diffing algorithm to match new S-expression parts to original
parts of the parse tree.
Usage

(use 'com.rpl.specter)
(use 'com.rpl.specter.macros)
(use 'com.maitria.specter-edn)

(select [SEXPR FIRST LAST] "[42 26 77]");=> 77

(setval [SEXPR FIRST FIRST] 99 "[42 ; Hi mom!\n6]");=> "[99 ; Hi mom!\n6]"

TODO

   - Use clj-format to format new code which isn't matched up with old code.

License

Copyright © 2016 FIXME

Distributed under the Eclipse Public License either version 1.0 or (at your
option) any later version.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What to read after 3 dozen "introduction to transducers" blog posts

2017-05-16 Thread Alexander Yakushev
This was beautiful. I was held in suspense through the whole story, and I 
cried in the end. But I must tell you that such sacrifices to data gods are 
justified, so I will keep reifying and transducing until the very last drop 
of bytes leaks from the oblatory value.

On Wednesday, May 10, 2017 at 10:16:42 AM UTC+3, Luke Burton wrote:
>
>
> > On May 6, 2017, at 10:56 AM, Matching Socks  > wrote: 
> > 
> > This one.  
> https://tech.grammarly.com/blog/building-etl-pipelines-with-clojure 
> > 
> > "To be honest, this is a somewhat advanced usage of the transducers 
> machinery," says the Grammarly Engineering Blog, right after shoehorning a 
> BufferedReader into the mold with "reify IReduceInit".  I already felt I'd 
> got my money's worth from reading up to this half-way point.  But I was 
> astonished at what came next.   
>
> Though it pains me to speak of it, I tell you now I have seen this "blog 
> post", and seen too what came next. Astonishing indeed! I admire your 
> simple description of these events, as it suggests either a man of great 
> fortitude in the face of horror, or a man who was able to flee and forget, 
> and I know that I am neither. 
>
> I remember the reified specimen – still alive, god have mercy – placed 
> upon an altar to be offered up to `eduction`. Yes! Placed squarely on its 
> unsightly variadic first argument. Why? For what purpose? We are told: 
> "it's a recipe for the values to come." The blood drained from my face. 
>
> It was soon apparent what eldritch function would feast upon the values 
> begotten by this unholy recipe. I saw the invocation of `transduce` and it 
> brought back sweeter memories, of burritos and airport conveyor belts. I 
> could see the `eduction`, presumably still wrapping the reified 
> IReduceInit, perched atop a ziggurat of lesser transducers. I looked, and 
> at the very bottom lay a blasphemous side-effectful invocation of map. I 
> did not belong in this place. 
>
> Beyond astonished, I tell you, but still at this point I clung to sanity. 
> I cried out: Enough! The values have suffered enough! They were good 
> values, persisted to disk, why are they now flung into dimensions far 
> beyond our own? Why have you turned your back on open(2)? Why have you 
> forsaken the file descriptor? 
>
> Alas, my sanity could not stand this final blow. The Grammarly necromancer 
> spoke the words: "Here Comes The Parallel Implementation." And lo, he did 
> throw `core.async` into the mix. I saw `pipeline` swallow `transduce` 
> whole, like a multi-armed multi-beaked creature from a Boschian hellscape. 
> The whine of the CPU fans drowned out my last cry: aren't you supposed to 
> use `pipeline-blocking`? 
>
> You may think me sane now in having told you all this, but I assure you, I 
> am no longer. I should have run when I had the chance, but now I dream of 
> educing the pipeline, reifying the transducer, and shouting the misbegotten 
> outcomes into every channel that will >!! my message. It is too late for 
> me, but perhaps not too late for you. 
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.