Scala for-comprehension to Clojure

2015-11-26 Thread Rastko Soskic
Hi, 
I am aware of philosophical differences of Scala and Clojure
but functional programming should be a pretty common ground :)
Thus I need help, I am trying to mimic Scala's for comprehension in Clojure.

Hopefully someone will be able to aid me with the following (perhaps more 
familiar with Scala):

Scala for comprehension is errr how to say "de-sugared" to series 
of map and flatMap calls... thus, it is possible to use plain functions in 
for-comprehension
like:
*val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for functions of 
type B => (B, A)
x <- int // int is function again of type Conv
y <- int
xs <- ints(x) // this is just sequence of numbers
} *yield *xs.map(_ * y)

I don't need all the nuts and bolts, just some guideline for achieving 
something similar
in Clojure.

I am not lazy :) I've already eagerly researched a bit and got to this: Scala 
for-comprehension to Clojure 


But as you can see that is not really about having kind of generator 
function which is wrapped into flatMap
call. Perhaps this is not in Clojure's spirit at all, perhaps there is some 
Clojure idiom to achieve something similar.

Any tip, suggestion, critic is welcome and appreciated.

If someone is wondering how in the world I came up to this, I am doing some 
f-p exercises which I've got Scala solution for
however I am not very interested in Scala and I am doing Clojure so I just 
need to grasp concepts...

Thanks in advance...

-- 
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: Scala for-comprehension to Clojure

2015-11-26 Thread Torsten Uhlmann
Hi Rastko,

One way of doing that would be to use the mlet macro from the Cats library: 
http://funcool.github.io/cats/latest/#mlet

Also, there are several if-lets or when-lets out there that allow multiple 
bindings, I used one from https://github.com/ptaoussanis/encore

I use Scala's for most of the time when there are Options in the mix that 
may or may not hold a value.

For binding to generators, Clojures for might be a better 
fit? https://clojuredocs.org/clojure.core/for

Would that help you?

Torsten.

PS: I'm learning Clojure myself with Scala and Java background.

On Thursday, November 26, 2015 at 12:12:01 PM UTC+1, Rastko Soskic wrote:
>
> Hi, 
> I am aware of philosophical differences of Scala and Clojure
> but functional programming should be a pretty common ground :)
> Thus I need help, I am trying to mimic Scala's for comprehension in 
> Clojure.
>
> Hopefully someone will be able to aid me with the following (perhaps more 
> familiar with Scala):
>
> Scala for comprehension is errr how to say "de-sugared" to series 
> of map and flatMap calls... thus, it is possible to use plain functions in 
> for-comprehension
> like:
> *val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for functions 
> of type B => (B, A)
> x <- int // int is function again of type Conv
> y <- int
> xs <- ints(x) // this is just sequence of numbers
> } *yield *xs.map(_ * y)
>
> I don't need all the nuts and bolts, just some guideline for achieving 
> something similar
> in Clojure.
>
> I am not lazy :) I've already eagerly researched a bit and got to this: Scala 
> for-comprehension to Clojure 
> 
>
> But as you can see that is not really about having kind of generator 
> function which is wrapped into flatMap
> call. Perhaps this is not in Clojure's spirit at all, perhaps there is 
> some Clojure idiom to achieve something similar.
>
> Any tip, suggestion, critic is welcome and appreciated.
>
> If someone is wondering how in the world I came up to this, I am doing 
> some f-p exercises which I've got Scala solution for
> however I am not very interested in Scala and I am doing Clojure so I just 
> need to grasp concepts...
>
> Thanks in advance...
>

-- 
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: Scala for-comprehension to Clojure

2015-11-26 Thread Gary Verhaegen
It's a bit hard (at least for me) to see what you're actually trying to do
here that would precent a direct translation of your snippet to Clojure's
for. Could you perhaps post a complete, self-contained code example in
Scala?

On Thursday, 26 November 2015, Torsten Uhlmann 
wrote:

> Hi Rastko,
>
> One way of doing that would be to use the mlet macro from the Cats
> library: http://funcool.github.io/cats/latest/#mlet
>
> Also, there are several if-lets or when-lets out there that allow multiple
> bindings, I used one from https://github.com/ptaoussanis/encore
>
> I use Scala's for most of the time when there are Options in the mix that
> may or may not hold a value.
>
> For binding to generators, Clojures for might be a better fit?
> https://clojuredocs.org/clojure.core/for
>
> Would that help you?
>
> Torsten.
>
> PS: I'm learning Clojure myself with Scala and Java background.
>
> On Thursday, November 26, 2015 at 12:12:01 PM UTC+1, Rastko Soskic wrote:
>>
>> Hi,
>> I am aware of philosophical differences of Scala and Clojure
>> but functional programming should be a pretty common ground :)
>> Thus I need help, I am trying to mimic Scala's for comprehension in
>> Clojure.
>>
>> Hopefully someone will be able to aid me with the following (perhaps more
>> familiar with Scala):
>>
>> Scala for comprehension is errr how to say "de-sugared" to series
>> of map and flatMap calls... thus, it is possible to use plain functions
>> in for-comprehension
>> like:
>> *val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for functions
>> of type B => (B, A)
>> x <- int // int is function again of type Conv
>> y <- int
>> xs <- ints(x) // this is just sequence of numbers
>> } *yield *xs.map(_ * y)
>>
>> I don't need all the nuts and bolts, just some guideline for achieving
>> something similar
>> in Clojure.
>>
>> I am not lazy :) I've already eagerly researched a bit and got to this: Scala
>> for-comprehension to Clojure
>> 
>>
>> But as you can see that is not really about having kind of generator
>> function which is wrapped into flatMap
>> call. Perhaps this is not in Clojure's spirit at all, perhaps there is
>> some Clojure idiom to achieve something similar.
>>
>> Any tip, suggestion, critic is welcome and appreciated.
>>
>> If someone is wondering how in the world I came up to this, I am doing
>> some f-p exercises which I've got Scala solution for
>> however I am not very interested in Scala and I am doing Clojure so I
>> just need to grasp concepts...
>>
>> Thanks in advance...
>>
> --
> 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.
>

-- 
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.


Current Cider SNAPSHOT not working??

2015-11-26 Thread Karel Miarka
I have just installed a new box and cannot make Cider working with 
Spacemacs nor Prelude.

When I open a .clj file I notice this in *Messages*:

*Eager macro-expansion failure: (error "Unknown upattern `(quote 
request)'")*

Then I try to connect to nREPL server C-c M-c and the REPL is not working. 
There is only this new *Messages*:

nREPL: Establishing direct connection to localhost:7002 ...
nREPL: Direct connection established
*pcase--u1: Unknown upattern `(quote request)'*

Google returns nothing searching "unknown upattern" "quote request".

My profiles.clj looks like this:

{:user {:plugins  [[cider/cider-nrepl "0.10.0-SNAPSHOT"]
   [refactor-nrepl "2.0.0-SNAPSHOT"]]
:dependencies [[alembic "0.3.2"]
   [org.clojure/tools.nrepl "0.2.11"]]}}

OS: Linux Mint/Ubuntu 64bit
Oracle Java 8
Clojure 1.7

Thanks for any help / suggestions!

-- 
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: Current Cider SNAPSHOT not working??

2015-11-26 Thread Lars Andersen
Some bad code slipped into master for a few minutes but was fixed promptly. 
See https://github.com/clojure-emacs/cider/issues/1434 for more details.

Just upgrade CIDER and you should be fine.

On Thursday, November 26, 2015 at 1:16:23 PM UTC+1, Karel Miarka wrote:
>
> I have just installed a new box and cannot make Cider working with 
> Spacemacs nor Prelude.
>
> When I open a .clj file I notice this in *Messages*:
>
> *Eager macro-expansion failure: (error "Unknown upattern `(quote 
> request)'")*
>
> Then I try to connect to nREPL server C-c M-c and the REPL is not working. 
> There is only this new *Messages*:
>
> nREPL: Establishing direct connection to localhost:7002 ...
> nREPL: Direct connection established
> *pcase--u1: Unknown upattern `(quote request)'*
>
> Google returns nothing searching "unknown upattern" "quote request".
>
> My profiles.clj looks like this:
>
> {:user {:plugins  [[cider/cider-nrepl "0.10.0-SNAPSHOT"]
>[refactor-nrepl "2.0.0-SNAPSHOT"]]
> :dependencies [[alembic "0.3.2"]
>[org.clojure/tools.nrepl "0.2.11"]]}}
>
> OS: Linux Mint/Ubuntu 64bit
> Oracle Java 8
> Clojure 1.7
>
> Thanks for any help / suggestions!
>
>

-- 
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: Scala for-comprehension to Clojure

2015-11-26 Thread Chris Murphy
It is the same thing in Clojure. It is called a 'list comprehension' even
although for form for it starts with `for`  I wouldn't worry too much about
the flatmap / mapcat stuff, as I think the translation should be quite
direct at the higher 'comprehension' level.
On Nov 26, 2015 10:12 PM, "Rastko Soskic"  wrote:

> Hi,
> I am aware of philosophical differences of Scala and Clojure
> but functional programming should be a pretty common ground :)
> Thus I need help, I am trying to mimic Scala's for comprehension in
> Clojure.
>
> Hopefully someone will be able to aid me with the following (perhaps more
> familiar with Scala):
>
> Scala for comprehension is errr how to say "de-sugared" to series
> of map and flatMap calls... thus, it is possible to use plain functions in
> for-comprehension
> like:
> *val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for functions
> of type B => (B, A)
> x <- int // int is function again of type Conv
> y <- int
> xs <- ints(x) // this is just sequence of numbers
> } *yield *xs.map(_ * y)
>
> I don't need all the nuts and bolts, just some guideline for achieving
> something similar
> in Clojure.
>
> I am not lazy :) I've already eagerly researched a bit and got to this: Scala
> for-comprehension to Clojure
> 
>
> But as you can see that is not really about having kind of generator
> function which is wrapped into flatMap
> call. Perhaps this is not in Clojure's spirit at all, perhaps there is
> some Clojure idiom to achieve something similar.
>
> Any tip, suggestion, critic is welcome and appreciated.
>
> If someone is wondering how in the world I came up to this, I am doing
> some f-p exercises which I've got Scala solution for
> however I am not very interested in Scala and I am doing Clojure so I just
> need to grasp concepts...
>
> Thanks in advance...
>
> --
> 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.
>

-- 
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: Current Cider SNAPSHOT not working??

2015-11-26 Thread Karel Miarka
Thanks a lot.

But whatever I do, I cannot get rid of the warnings:

; CIDER 0.10.0snapshot (package: 20151125.1430) (Java 1.8.0_66, Clojure 
1.7.0, nREPL 0.2.12)
WARNING: The following required nREPL ops are not supported: 
apropos classpath complete eldoc format-code format-edn info inspect-pop 
inspect-push inspect-refresh macroexpand ns-list ns-vars ns-path refresh 
resource stacktrace toggle-trace-var toggle-trace-ns undef
Please, install (or update) cider-nrepl 0.10.0-SNAPSHOT and restart CIDER
WARNING: The following nREPL ops are not supported:
artifact-list artifact-versions clean-ns extract-definition find-symbol 
find-used-locals hotload-dependency namespace-aliases rename-file-or-dir 
resolve-missing stubs-for-interface version warm-ast-cache
Please, install (or update) refactor-nrepl and restart the REPL.
You can mute this warning by changing cljr-suppress-middleware-warnings.
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.0.0-SNAPSHOT (package: 20151112.117) and n/a, 
respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.


And I believe my profiles.clj is ok:

{:user {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]
  [refactor-nrepl "2.0.0-SNAPSHOT"]]
:dependencies [[org.clojure/tools.nrepl "0.2.12"]]
}}


I have completely removed ~/.emacs.d/ and also all the snapshots from ~/.m2 
repo.
Upgraded Emacs from 24.4 to 24.5 .
Run lein upgrade.
No success...
What can be wrong?


On Thursday, November 26, 2015 at 1:30:07 PM UTC+1, Lars Andersen wrote:
>
> Some bad code slipped into master for a few minutes but was fixed 
> promptly. See https://github.com/clojure-emacs/cider/issues/1434 for more 
> details.
>
> Just upgrade CIDER and you should be fine.
>
>
>

-- 
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: Scala for-comprehension to Clojure

2015-11-26 Thread Rastko Soskic
Hi, I am not sure if it will serve point the best but that is what I have 
received as a koan style problem with Scala solution,
now I am trying to comprehend it fully and convert to Clojure. Like I said 
I am by no means Scala expert.

Let's say we have some Val container which is capable to hold some value 
plus yield another value 
which depends on "mapping" function provided to Val itself (exec param of 
case class).

package question.google.group

object worksheet {
  def unit[S, A](a: A): Val[S, A] =
Val(s => (a, s)) 

  case class Val[S, +A](exec: S => (A, S)) {
def map[B](f: A => B): Val[S, B] =
  flatMap(a => unit(f(a)))
def flatMap[B](f: A => Val[S, B]): Val[S, B] = Val(s => {
  val (a, s1) = exec(s)
  f(a).exec(s1)
})
  }
  
  def int : Val[Int, Int] = Val(x => (x, x + 1)) 

*  val something = for {*
*x <- int*
*y <- int*
*  } yield (x, y)  //> something 
 : question.google.group.Val[Int,(Int, Int)] = Val()*
  
  something.exec(5)   //> res9: ((Int, Int), 
Int) = ((5,6),7)
}

If I am following this example and wikipedia well (on Monads in fp), 
in bottom line Val is a monad given presence of type unit and bind 
(flatMap) operation... But that is not my primary focus here.

It is Scala's for comprehension which expands to map and flatMap calls so 
some intial value (given to exec function) "flows" through it
yielding in the end expected result.

I hope this sheds some more light on what I am seeking for.

@Torsten, thanks for mentioned resources I'll take a look at them.

On Thursday, November 26, 2015 at 12:40:50 PM UTC+1, Gary Verhaegen wrote:
>
> It's a bit hard (at least for me) to see what you're actually trying to do 
> here that would precent a direct translation of your snippet to Clojure's 
> for. Could you perhaps post a complete, self-contained code example in 
> Scala?
>
> On Thursday, 26 November 2015, Torsten Uhlmann  > wrote:
>
>> Hi Rastko,
>>
>> One way of doing that would be to use the mlet macro from the Cats 
>> library: http://funcool.github.io/cats/latest/#mlet
>>
>> Also, there are several if-lets or when-lets out there that allow 
>> multiple bindings, I used one from https://github.com/ptaoussanis/encore
>>
>> I use Scala's for most of the time when there are Options in the mix that 
>> may or may not hold a value.
>>
>> For binding to generators, Clojures for might be a better fit? 
>> https://clojuredocs.org/clojure.core/for
>>
>> Would that help you?
>>
>> Torsten.
>>
>> PS: I'm learning Clojure myself with Scala and Java background.
>>
>> On Thursday, November 26, 2015 at 12:12:01 PM UTC+1, Rastko Soskic wrote:
>>>
>>> Hi, 
>>> I am aware of philosophical differences of Scala and Clojure
>>> but functional programming should be a pretty common ground :)
>>> Thus I need help, I am trying to mimic Scala's for comprehension in 
>>> Clojure.
>>>
>>> Hopefully someone will be able to aid me with the following (perhaps 
>>> more familiar with Scala):
>>>
>>> Scala for comprehension is errr how to say "de-sugared" to series 
>>> of map and flatMap calls... thus, it is possible to use plain functions 
>>> in for-comprehension
>>> like:
>>> *val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for functions 
>>> of type B => (B, A)
>>> x <- int // int is function again of type Conv
>>> y <- int
>>> xs <- ints(x) // this is just sequence of numbers
>>> } *yield *xs.map(_ * y)
>>>
>>> I don't need all the nuts and bolts, just some guideline for achieving 
>>> something similar
>>> in Clojure.
>>>
>>> I am not lazy :) I've already eagerly researched a bit and got to this: 
>>> Scala 
>>> for-comprehension to Clojure 
>>> 
>>>
>>> But as you can see that is not really about having kind of generator 
>>> function which is wrapped into flatMap
>>> call. Perhaps this is not in Clojure's spirit at all, perhaps there is 
>>> some Clojure idiom to achieve something similar.
>>>
>>> Any tip, suggestion, critic is welcome and appreciated.
>>>
>>> If someone is wondering how in the world I came up to this, I am doing 
>>> some f-p exercises which I've got Scala solution for
>>> however I am not very interested in Scala and I am doing Clojure so I 
>>> just need to grasp concepts...
>>>
>>> Thanks in advance...
>>>
>> -- 
>> 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 
>> "Cloj

Re: Scala for-comprehension to Clojure

2015-11-26 Thread Mark Engelberg
Most Scala `for` examples translate over to Clojure's `for`.  The biggest
difference is that Scala produces a collection matching the type of the
first generator, whereas Clojure produces a lazy sequence, which you can
"pour" into the collection of your choice with `into`.

It looks like your specific example is also using some sort of imperative
generator in Scala.  Clojure tends to frown on those sorts of constructs,
and is more prescriptive, guiding you towards a more functional solution.
You might rework that generator as a lazy sequence.  Or possibly, if you
really need something more imperative in nature, you could represent the
generator as a channel and you could accomplish what you want with
transducers on the channel (I'm not aware of a for-like macro that operates
on channels, but it seems theoretically possible to write such a thing).


On Thu, Nov 26, 2015 at 8:16 AM, Rastko Soskic  wrote:

> Hi, I am not sure if it will serve point the best but that is what I have
> received as a koan style problem with Scala solution,
> now I am trying to comprehend it fully and convert to Clojure. Like I said
> I am by no means Scala expert.
>
> Let's say we have some Val container which is capable to hold some value
> plus yield another value
> which depends on "mapping" function provided to Val itself (exec param of
> case class).
>
> package question.google.group
>
> object worksheet {
>   def unit[S, A](a: A): Val[S, A] =
> Val(s => (a, s))
>
>   case class Val[S, +A](exec: S => (A, S)) {
> def map[B](f: A => B): Val[S, B] =
>   flatMap(a => unit(f(a)))
> def flatMap[B](f: A => Val[S, B]): Val[S, B] = Val(s => {
>   val (a, s1) = exec(s)
>   f(a).exec(s1)
> })
>   }
>
>   def int : Val[Int, Int] = Val(x => (x, x + 1))
>
> *  val something = for {*
> *x <- int*
> *y <- int*
> *  } yield (x, y)  //> something
>  : question.google.group.Val[Int,(Int, Int)] = Val()*
>
>   something.exec(5)   //> res9: ((Int, Int),
> Int) = ((5,6),7)
> }
>
> If I am following this example and wikipedia well (on Monads in fp),
> in bottom line Val is a monad given presence of type unit and bind
> (flatMap) operation... But that is not my primary focus here.
>
> It is Scala's for comprehension which expands to map and flatMap calls so
> some intial value (given to exec function) "flows" through it
> yielding in the end expected result.
>
> I hope this sheds some more light on what I am seeking for.
>
> @Torsten, thanks for mentioned resources I'll take a look at them.
>
> On Thursday, November 26, 2015 at 12:40:50 PM UTC+1, Gary Verhaegen wrote:
>>
>> It's a bit hard (at least for me) to see what you're actually trying to
>> do here that would precent a direct translation of your snippet to
>> Clojure's for. Could you perhaps post a complete, self-contained code
>> example in Scala?
>>
>> On Thursday, 26 November 2015, Torsten Uhlmann 
>> wrote:
>>
>>> Hi Rastko,
>>>
>>> One way of doing that would be to use the mlet macro from the Cats
>>> library: http://funcool.github.io/cats/latest/#mlet
>>>
>>> Also, there are several if-lets or when-lets out there that allow
>>> multiple bindings, I used one from https://github.com/ptaoussanis/encore
>>>
>>> I use Scala's for most of the time when there are Options in the mix
>>> that may or may not hold a value.
>>>
>>> For binding to generators, Clojures for might be a better fit?
>>> https://clojuredocs.org/clojure.core/for
>>>
>>> Would that help you?
>>>
>>> Torsten.
>>>
>>> PS: I'm learning Clojure myself with Scala and Java background.
>>>
>>> On Thursday, November 26, 2015 at 12:12:01 PM UTC+1, Rastko Soskic wrote:

 Hi,
 I am aware of philosophical differences of Scala and Clojure
 but functional programming should be a pretty common ground :)
 Thus I need help, I am trying to mimic Scala's for comprehension in
 Clojure.

 Hopefully someone will be able to aid me with the following (perhaps
 more familiar with Scala):

 Scala for comprehension is errr how to say "de-sugared" to series
 of map and flatMap calls... thus, it is possible to use plain functions
 in for-comprehension
 like:
 *val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for
 functions of type B => (B, A)
 x <- int // int is function again of type Conv
 y <- int
 xs <- ints(x) // this is just sequence of numbers
 } *yield *xs.map(_ * y)

 I don't need all the nuts and bolts, just some guideline for achieving
 something similar
 in Clojure.

 I am not lazy :) I've already eagerly researched a bit and got to this: 
 Scala
 for-comprehension to Clojure
 

 But as you can see that is not really about having kind of generator
 function which is wrapped into flatMap

Re: Current Cider SNAPSHOT not working??

2015-11-26 Thread Artur Malabarba
Looks like your plugins are not getting pulled by leiningen.

Delete your .m2/ snapshots and then start lein repl in a terminal. Do you
see the plugins being pulled?

In this repl, are you able to require cider namespaces? Try: (require
'cider.nrepl.middleware.debug)
On 26 Nov 2015 1:47 pm, "Karel Miarka"  wrote:

> Thanks a lot.
>
> But whatever I do, I cannot get rid of the warnings:
>
> ; CIDER 0.10.0snapshot (package: 20151125.1430) (Java 1.8.0_66, Clojure
> 1.7.0, nREPL 0.2.12)
> WARNING: The following required nREPL ops are not supported:
> apropos classpath complete eldoc format-code format-edn info inspect-pop
> inspect-push inspect-refresh macroexpand ns-list ns-vars ns-path refresh
> resource stacktrace toggle-trace-var toggle-trace-ns undef
> Please, install (or update) cider-nrepl 0.10.0-SNAPSHOT and restart CIDER
> WARNING: The following nREPL ops are not supported:
> artifact-list artifact-versions clean-ns extract-definition find-symbol
> find-used-locals hotload-dependency namespace-aliases rename-file-or-dir
> resolve-missing stubs-for-interface version warm-ast-cache
> Please, install (or update) refactor-nrepl and restart the REPL.
> You can mute this warning by changing cljr-suppress-middleware-warnings.
> WARNING: clj-refactor and refactor-nrepl are out of sync.
> Their versions are 2.0.0-SNAPSHOT (package: 20151112.117) and n/a,
> respectively.
> You can mute this warning by changing cljr-suppress-middleware-warnings.
>
>
> And I believe my profiles.clj is ok:
>
> {:user {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]
>   [refactor-nrepl "2.0.0-SNAPSHOT"]]
> :dependencies [[org.clojure/tools.nrepl "0.2.12"]]
> }}
>
>
> I have completely removed ~/.emacs.d/ and also all the snapshots from
> ~/.m2 repo.
> Upgraded Emacs from 24.4 to 24.5 .
> Run lein upgrade.
> No success...
> What can be wrong?
>
>
> On Thursday, November 26, 2015 at 1:30:07 PM UTC+1, Lars Andersen wrote:
>>
>> Some bad code slipped into master for a few minutes but was fixed
>> promptly. See https://github.com/clojure-emacs/cider/issues/1434 for
>> more details.
>>
>> Just upgrade CIDER and you should be fine.
>>
>>
>> --
> 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.
>

-- 
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.