Haskell for Imperative Programmers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Haskell for Imperative Programmers

Olivier Revollat
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

Paul

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

Olivier Revollat
Thanks !

Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]> a écrit :

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

Theodore Lief Gannon
An intuition that really clicked for me is that in Haskell IO code, as in all Haskell code, you are describing a pristine and perfectly inert data structure. It happens to *represent* a set of imperative instructions that the totally impure runtime environment can execute, but that's not your problem!

On Tue, Jul 10, 2018, 4:55 AM Olivier Revollat <[hidden email]> wrote:
Thanks !

Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]> a écrit :

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

Olivier Revollat
Yes absolutely ! you're referring to laziness right ?


Le mar. 10 juil. 2018 à 14:20, Theodore Lief Gannon <[hidden email]> a écrit :
An intuition that really clicked for me is that in Haskell IO code, as in all Haskell code, you are describing a pristine and perfectly inert data structure. It happens to *represent* a set of imperative instructions that the totally impure runtime environment can execute, but that's not your problem!

On Tue, Jul 10, 2018, 4:55 AM Olivier Revollat <[hidden email]> wrote:
Thanks !

Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]> a écrit :

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

"Ionuț G. Stan"
In reply to this post by Theodore Lief Gannon
On 10/07/2018 15:19, Theodore Lief Gannon wrote:
> An intuition that really clicked for me is that in Haskell IO code, as
> in all Haskell code, you are describing a pristine and perfectly inert
> data structure. It happens to *represent* a set of imperative
> instructions that the totally impure runtime environment can execute,
> but that's not your problem!

Just like in Java :) I'm kinda trolling a bit, but if I spend all my dev
time inside an IO monad of sorts, I don't find that to be much different
than writing Java.


> On Tue, Jul 10, 2018, 4:55 AM Olivier Revollat <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Thanks !
>
>     Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]
>     <mailto:[hidden email]>> a écrit :
>
>         May be something like this?
>
>         *Free monads* ("applicative" style/interpreting trees) and Effects:
>
>         https://markkarpov.com/post/free-monad-considered-harmful.html
>         https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue
>
>         *Arrows* (something like "flow"-style):
>         https://www.haskell.org/arrows/
>         http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html
>
>
>         10.07.2018 12:22, Olivier Revollat wrote:
>>         Hi,
>>         I've been using imperative languages for 20 years now :)
>>
>>         I'm a beginner in haskell and I love the paradigm shift you
>>         feel when you come from imperative programming. I found
>>         interesting articles like :
>>         https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers
>>
>>         Do you have any other ressources like that ?
>>         I'm not looking for how to use haskell in imperative style
>>         (e.g. with "do" notation, ...) no no ! I'm looking articles
>>         who explain how NOT TO USE imperative style with haskell, and
>>         help thinking the paradigm shift ...
>>
>>         Thanks :)
>>
>>
>>
>>         _______________________________________________
>>         Beginners mailing list
>>         [hidden email] <mailto:[hidden email]>
>>         http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>         _______________________________________________
>         Beginners mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>     _______________________________________________
>     Beginners mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>


--
Ionuț G. Stan  |  http://igstan.ro  |  http://bucharestfp.ro
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

David McBride
In reply to this post by Olivier Revollat
No, he means that an IO action is just another type.  For example you can have a list of IO actions, Then you can take one of them and execute them.  Then you can execute that one action again as many times as you want, because an IO action is just a type like any other type until it is executed.  These examples are utterly contrived.

foo :: [IO String]
foo = [return "25", print "hello" >> return "qwerty", getLine]

foo !! 3 :: IO String

bar :: [IO Int]
bar = map (fmap read) foo

main :: IO ()
main = do
  str <- foo !! 2 
  print str
  str2 <- foo !! 2
  print str2
  i <- head bar
  print (i + 1)

Even main is just a data structure until the compiler decides to execute it.  It could have been written as an expression.

main = foo !! 2 >>= \str -> print str >> foo !! 2 >>= \str2 -> print str2 >> head bar >>= \i -> print (i + 1)






On Tue, Jul 10, 2018 at 8:29 AM, Olivier Revollat <[hidden email]> wrote:
Yes absolutely ! you're referring to laziness right ?


Le mar. 10 juil. 2018 à 14:20, Theodore Lief Gannon <[hidden email]> a écrit :
An intuition that really clicked for me is that in Haskell IO code, as in all Haskell code, you are describing a pristine and perfectly inert data structure. It happens to *represent* a set of imperative instructions that the totally impure runtime environment can execute, but that's not your problem!

On Tue, Jul 10, 2018, 4:55 AM Olivier Revollat <[hidden email]> wrote:
Thanks !

Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]> a écrit :

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

Paul

More interesting example from Gabriel Gonzalez: http://www.haskellforall.com/2018/02/the-wizard-monoid.html  :)


10.07.2018 15:50, David McBride wrote:
No, he means that an IO action is just another type.  For example you can have a list of IO actions, Then you can take one of them and execute them.  Then you can execute that one action again as many times as you want, because an IO action is just a type like any other type until it is executed.  These examples are utterly contrived.

foo :: [IO String]
foo = [return "25", print "hello" >> return "qwerty", getLine]

foo !! 3 :: IO String

bar :: [IO Int]
bar = map (fmap read) foo

main :: IO ()
main = do
  str <- foo !! 2 
  print str
  str2 <- foo !! 2
  print str2
  i <- head bar
  print (i + 1)

Even main is just a data structure until the compiler decides to execute it.  It could have been written as an expression.

main = foo !! 2 >>= \str -> print str >> foo !! 2 >>= \str2 -> print str2 >> head bar >>= \i -> print (i + 1)






On Tue, Jul 10, 2018 at 8:29 AM, Olivier Revollat <[hidden email]> wrote:
Yes absolutely ! you're referring to laziness right ?


Le mar. 10 juil. 2018 à 14:20, Theodore Lief Gannon <[hidden email]> a écrit :
An intuition that really clicked for me is that in Haskell IO code, as in all Haskell code, you are describing a pristine and perfectly inert data structure. It happens to *represent* a set of imperative instructions that the totally impure runtime environment can execute, but that's not your problem!

On Tue, Jul 10, 2018, 4:55 AM Olivier Revollat <[hidden email]> wrote:
Thanks !

Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]> a écrit :

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners




_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Haskell for Imperative Programmers

Theodore Lief Gannon
Thank you David and PY, that is exactly what I meant. And of course, Gabriel's blog knocks it out of the park as usual!

On Tue, Jul 10, 2018, 6:06 AM PY <[hidden email]> wrote:

More interesting example from Gabriel Gonzalez: http://www.haskellforall.com/2018/02/the-wizard-monoid.html  :)


10.07.2018 15:50, David McBride wrote:
No, he means that an IO action is just another type.  For example you can have a list of IO actions, Then you can take one of them and execute them.  Then you can execute that one action again as many times as you want, because an IO action is just a type like any other type until it is executed.  These examples are utterly contrived.

foo :: [IO String]
foo = [return "25", print "hello" >> return "qwerty", getLine]

foo !! 3 :: IO String

bar :: [IO Int]
bar = map (fmap read) foo

main :: IO ()
main = do
  str <- foo !! 2 
  print str
  str2 <- foo !! 2
  print str2
  i <- head bar
  print (i + 1)

Even main is just a data structure until the compiler decides to execute it.  It could have been written as an expression.

main = foo !! 2 >>= \str -> print str >> foo !! 2 >>= \str2 -> print str2 >> head bar >>= \i -> print (i + 1)






On Tue, Jul 10, 2018 at 8:29 AM, Olivier Revollat <[hidden email]> wrote:
Yes absolutely ! you're referring to laziness right ?


Le mar. 10 juil. 2018 à 14:20, Theodore Lief Gannon <[hidden email]> a écrit :
An intuition that really clicked for me is that in Haskell IO code, as in all Haskell code, you are describing a pristine and perfectly inert data structure. It happens to *represent* a set of imperative instructions that the totally impure runtime environment can execute, but that's not your problem!

On Tue, Jul 10, 2018, 4:55 AM Olivier Revollat <[hidden email]> wrote:
Thanks !

Le mar. 10 juil. 2018 à 13:14, PY <[hidden email]> a écrit :

May be something like this?

Free monads ("applicative" style/interpreting trees) and Effects:

https://markkarpov.com/post/free-monad-considered-harmful.html
https://mmhaskell.com/blog/2017/11/20/eff-to-the-rescue

Arrows (something like "flow"-style):
https://www.haskell.org/arrows/
http://tuttlem.github.io/2014/07/26/practical-arrow-usage.html


10.07.2018 12:22, Olivier Revollat wrote:
Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do" notation, ...) no no ! I'm looking articles who explain how NOT TO USE imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners




_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners