Daniel Sobral | 1 Nov 01:09 2011
Picon

Re: zsh completion definitions for scala and scalac

Consider adding it to the wiki about tools and libraries:
https://wiki.scala-lang.org/display/SW/Tools+and+Libraries.

On Mon, Oct 31, 2011 at 21:56, Tony Sloane <inkytonik@...> wrote:
> Hi all,
>
> If you are a zsh user, you may be interested in a completion definition
> I have recently built for the scala and scalac commands.
>
> You can get more information and download the definition at
>
>   https://bitbucket.org/inkytonik/zsh-completion
>
> Bug fixes and other contributions are welcome.
>
> cheers,
> Tony
>
>

--

-- 
Daniel C. Sobral

I travel to the future all the time.

Andrei Pozolotin | 1 Nov 01:16 2011
Picon

Re: Generics in Scala: implementing an interface/trait twice?

 <at> Eugene:

On Oct 30, 3:26 pm, Eugene Burmako <xeno...@...> wrote:
> Hi Martin,
>
> From the most recent message of Andrei, I assumed that it's not the
> actual inheritance scenario that is important, but rather the desire
> to satisfy multiple similar contracts.

correct.

>  <at> Andrei Long story short, macros provide a workaround for your
> scenario. It will be possible to write code that is similar to what
> you've written, and it will work,

great!

do you by chance have an example somewhere on github?

thanks;

Andrei.

Andrei Pozolotin | 1 Nov 01:23 2011
Picon

Re: Generics in Scala: implementing an interface/trait twice?

 <at> Martin:

On Oct 30, 2:59 pm, martin odersky <martin.oder...@...> wrote:
>
> I doubt that. Or at least you have to explain what kind of code you intend
> to generate and how you change typechecking. The restriction to a single
> interface instance is burned into both the typechecker and the JVM bytecode
> model.
>

in my example above I assumed that scala would generate
bunch of synthetic interfaces on the fly, to merge macros:

// this is java
interface $some$auto$generated$interface extends $binder$Runnable,
$binder$Callable {
 <at> Override
protected void bind(Runnable service) {}
 <at> Override
protected void bind(Callable service) {}
// ...
}

so it is still a single interface instance;

cheers,

Andrei.

(Continue reading)

Andrei Pozolotin | 1 Nov 01:33 2011
Picon

Re: Generics in Scala: implementing an interface/trait twice?

 <at> Eugene:

On Oct 30, 3:36 pm, Eugene Burmako <xeno...@...> wrote:
>  <at> Simon Yep, thanks to reification, it is possible to inherit from
> multiple generic interfaces that differ only in type arguments.
> Overloads are resolved using an algorithm that is similar to Scala's.
> If there are multiple candidates for an invocation, the algorithm
> tries to pick the most specific one.

this is not my use case, :-)

but : why not apply the same approach with help of scala manifests?
(behind the scene, w/o exposing programmer to manifests themselves)

Andrei.

Vlad Patryshev | 1 Nov 04:05 2011
Picon

Re: T <- IO T?

You can only do it while within IO.

Thanks,
-Vlad


On Mon, Oct 31, 2011 at 7:37 AM, amulya rattan <talk2amulya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Dear Scalites,

Trying to get better intuitions about monads, I was watching a couple of videos by Merdith Gregory and Erik Meijer respectively. Excellent stuff but one thing that confused me. Meredith described monads as somthing that you can't take things out of, you can only do that with comonads. Looking at the functions that it has, it seems so too. However, since do/for notations in Haskell/Scala have syntax of type, from one of Erik's videos on monads:

T <- IO T

which suggest that if you have a getStr of type IO T, you get the T out. Now if Monads don't allow you to take things out of them, how does the above happen? Appreciate any replies,

Thanks,
~Amulya

Vlad Patryshev | 1 Nov 04:21 2011
Picon

Re: Help to write this code block in a nicer scala way

Why all those ifs? Just convert items to a map, and then extract what you need, no?
 
Thanks,
-Vlad


On Mon, Oct 31, 2011 at 4:38 AM, Francesco Di Muccio <francesco.dimuccio-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi all,

I'm studying scala, and in the process I'm converting some server side java code in scala. I have this codeblock that parse the post request and extract the form fields:

val items = uploadHandler.parseRequest(req)
var title = ""
var description = ""
var file: FileItem = _
for(item: FileItem <- items) {
    if (item.isFormField) {
        item.getFieldName match {
            case "title"            => title = item.getString
            case "description" => description = item.getString
        }
    } else {
        file = item
    }
}

I don't like the vars and there should be a more coincise way to write this (maybe with for comprehension), any help?

Thank you
Francesco

Tony Sloane | 1 Nov 05:54 2011
Picon

Re: zsh completion definitions for scala and scalac

Good idea.  Done.

thanks,
Tony

On 01/11/2011, at 11:09 AM, Daniel Sobral wrote:

> Consider adding it to the wiki about tools and libraries:
> https://wiki.scala-lang.org/display/SW/Tools+and+Libraries.
> 
> On Mon, Oct 31, 2011 at 21:56, Tony Sloane <inkytonik@...> wrote:
>> Hi all,
>> 
>> If you are a zsh user, you may be interested in a completion definition
>> I have recently built for the scala and scalac commands.
>> 
>> You can get more information and download the definition at
>> 
>>   https://bitbucket.org/inkytonik/zsh-completion
>> 
>> Bug fixes and other contributions are welcome.
>> 
>> cheers,
>> Tony
>> 
>> 
> 
> 
> 
> -- 
> Daniel C. Sobral
> 
> I travel to the future all the time.

Jesper Nordenberg | 1 Nov 07:41 2011
Picon

Re: T <- IO T?

Remember that "x <- y" is simply syntactic sugar for "x.flatMap(y =>" in 
Scala and "x >>= \y ->" in Haskell. So your not really taking out a 
value of the monad, but rather sending a function to it that operates on 
the value.

/Jesper Nordenberg

amulya rattan skrev 2011-10-31 15:37:
> Dear Scalites,
>
> Trying to get better intuitions about monads, I was watching a couple of
> videos by Merdith Gregory and Erik Meijer respectively. Excellent stuff
> but one thing that confused me. Meredith described monads as somthing
> that you can't take things out of, you can only do that with comonads.
> Looking at the functions that it has, it seems so too. However, since
> do/for notations in Haskell/Scala have syntax of type, from one of
> Erik's videos on monads:
>
> T <- IO T
>
> which suggest that if you have a getStr of type IO T, you get the T out.
> Now if Monads don't allow you to take things out of them, how does the
> above happen? Appreciate any replies,
>
> Thanks,
> ~Amulya

Adam Jorgensen | 1 Nov 08:44 2011
Picon

Re: zsh completion definitions for scala and scalac

Awesome

On 1 November 2011 06:54, Tony Sloane <inkytonik <at> gmail.com> wrote:
Good idea.  Done.

thanks,
Tony

On 01/11/2011, at 11:09 AM, Daniel Sobral wrote:

> Consider adding it to the wiki about tools and libraries:
> https://wiki.scala-lang.org/display/SW/Tools+and+Libraries.
>
> On Mon, Oct 31, 2011 at 21:56, Tony Sloane <inkytonik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> Hi all,
>>
>> If you are a zsh user, you may be interested in a completion definition
>> I have recently built for the scala and scalac commands.
>>
>> You can get more information and download the definition at
>>
>>   https://bitbucket.org/inkytonik/zsh-completion
>>
>> Bug fixes and other contributions are welcome.
>>
>> cheers,
>> Tony
>>
>>
>
>
>
> --
> Daniel C. Sobral
>
> I travel to the future all the time.


amulya rattan | 1 Nov 10:17 2011
Picon

Interpretations of papers on functional programming

Dear Scalites,


I am not sure if this is the right place for raising this topic but it seems to be the closest. When entering the functional programming world, you are introduced to a whole massive heap of new concepts, explained through a number of papers on them. For someone without a background in functional programming, understanding them completely is certainly an uphill task. You can understand some parts of them but most of it just seems requiring reading a lot of other stuff like lambda calculus, different notations which seem a bit alien, which i personally dont mind, but time is always a problem. 

So my primary question is: Is anybody aware of some blogpost/video/tutorial explaining fundamentals for understanding these papers? Now of course there are too many papers on functional programming, but I am interested in papers which lead to scala/scalaz/haskell. Specifically ones that lead to use of monads/applicative functors   For example, while trying to read "The essence of the iterator pattern", i felt like i grokked 60% of it but rest was still hazy. Then I stumbled upon a fantastic blog entry on the same by Eric Torreborre, which was my crystallizing moment and everything just fell in its right place. A better understanding of that also helped in understanding "Applicative programming with Effects", although I guess in an opposite order. 

Further, there are many blogposts/videos which ease-in the concepts of monads and provide rather simplistic view of monads and one starts thinking "oh yeh, I get monads now!". All I need is a "return" to lift my value and a "bind" to do sequential computations, with identity and associativity laws...easy enough. But then I saw the way Gregory Meredith is using monads to create whole new design patterns for the web and i start thinking that i probably don't get them completely cuz I could have never thought of anything like that, given my understanding of monads(for e.g. the way he is using monads as continuations). Obviously I am not trying to compare my mental/intellectual ability with that of Gregory who seems to be a uber-mathemetician with uber-CS skills but I feel like I don't have better intuition about monads and other functional concepts probably cuz I never fully understood those papers. I am talking about papers like "Notion of computations and monads", "Theorams for free", "The essence of functional programming", "Functional programming with monads", "Functional programming with bananas, lenses, envelopes and barbed wires" etc. I feel like I won't get functional programming at its core, until I grok these papers completely. 

So I rephrase my question again: Is there any text/media explaining these papers using a language like Scala, given that most of these papers are already using Haskell? Or something that just explains the different notations, enough lambda calculus to understand these papers? Thanks for reading this and any response is deeply appreciated.

Thanks,
~Amulya

Gmane