Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Haskell code optimisation (Abhishek Kumar)
   2. Re:  Haskell code optimisation (Dimitri DeFigueiredo)
   3.  explaining effects (was: Doubts about    functional programming
      paradigm) (Daniel Bergey)
   4.  Trouble understanding the type of sequence       [Just, Just] (Lim H.)


----------------------------------------------------------------------

Message: 1
Date: Sat, 12 Dec 2015 18:05:25 +0530
From: Abhishek Kumar <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell code optimisation
Message-ID:
        <CAEAgXqUwYuk__jYNdJLTbi-r90QoY76DnGLqdr9up=2cqhf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Compiling below code (ghc --make) still doesn't gives result on my i3
Ubuntu 64bit machine.Can u please elaborate optimisations you did?
Thanks
Abhishek

On Friday, December 11, 2015, Kim-Ee Yeoh <[email protected]> wrote:

> Have you tried BangPatterns? Compiled with optimization, I get 22 secs.
> Here's the full program:
>
> {-# LANGUAGE BangPatterns #-}
>
> f :: Int -> Int -> Int
> f !m !n
>    | m==0      = n+1
>    | n==0      = f (m-1) 1
>    | otherwise = f (m-1) (f m (n-1))
>
> main = putStrLn (show (f 4 1))
>
>
> -- Kim-Ee
>
> On Fri, Dec 11, 2015 at 9:47 PM, Abhishek Kumar <[email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:
>
>> I was trying to write below program for ackerman function but it fails
>> (waits too long) for ack(4,1) whereas a recursive C program gives result in
>> 37secs.Can someone pls explain this behaviour and recomend some
>> optimisation.
>>
>> ------haskell code
>> f m n  | m==0 =n+1
>>            | n==0 = f  (m-1) 1
>>            | otherwise = f (m-1) (f m (n-1))
>>
>> Thanks
>> Abhishek Kumar
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> <javascript:_e(%7B%7D,'cvml','[email protected]');>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151212/f604b6f9/attachment-0001.html>

------------------------------

Message: 2
Date: Sat, 12 Dec 2015 10:57:11 -0200
From: Dimitri DeFigueiredo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell code optimisation
Message-ID: <[email protected]>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"

with 'ghc -O2' this takes 14 seconds on my macbook pro.

Dimitri

On 12/12/15 10:35 AM, Abhishek Kumar wrote:
> Compiling below code (ghc --make) still doesn't gives result on my i3 
> Ubuntu 64bit machine.Can u please elaborate optimisations you did?
> Thanks
> Abhishek
>
> On Friday, December 11, 2015, Kim-Ee Yeoh <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Have you tried BangPatterns? Compiled with optimization, I get 22
>     secs. Here's the full program:
>
>     {-# LANGUAGE BangPatterns #-}
>
>     f :: Int -> Int -> Int
>     f !m !n
>        | m==0      = n+1
>        | n==0      = f (m-1) 1
>        | otherwise = f (m-1) (f m (n-1))
>
>     main = putStrLn (show (f 4 1))
>
>
>     -- Kim-Ee
>
>     On Fri, Dec 11, 2015 at 9:47 PM, Abhishek Kumar
>     <[email protected]
>     <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:
>
>         I was trying to write below program for ackerman function but
>         it fails (waits too long) for ack(4,1) whereas a recursive C
>         program gives result in 37secs.Can someone pls explain this
>         behaviour and recomend some optimisation.
>
>         ------haskell code
>         f m n  | m==0 =n+1
>                    | n==0 = f  (m-1) 1
>                    | otherwise = f (m-1) (f m (n-1))
>
>         Thanks
>         Abhishek Kumar
>
>         _______________________________________________
>         Beginners mailing list
>         [email protected]
>         <javascript:_e(%7B%7D,'cvml','[email protected]');>
>         http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151212/8e52f93f/attachment-0001.html>

------------------------------

Message: 3
Date: Sat, 12 Dec 2015 08:38:44 -0500
From: Daniel Bergey <[email protected]>
To: Christopher Allen <[email protected]>, The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <[email protected]>
Subject: [Haskell-beginners] explaining effects (was: Doubts about
        functional programming paradigm)
Message-ID:
        <871taraisb.fsf@chladni.i-did-not-set--mail-host-address--so-tickle-me>
        
Content-Type: text/plain

I have pedagogical questions.  Why do you prefer "effect" to "side
effect"?  I know that "pure" is misleading to programmers new to
Haskell, but I have thought that "side effect" was more likely to be
self-explanatory.

I also reach for longer phrases like "free from side effects" if I'm
talking to my students.

cheers,
bergey

On 2015-12-11 at 16:36, Christopher Allen <[email protected]> wrote:
> Side bar: although using "pure" with respect to effects is the common usage
> now, I'd urge you to consider finding a different wording since the
> original (and IMHO more meaningful) denotation of pure functional
> programming was about semantics and not the presence or absence of effects.
> The meaning was that you had a programming language whose semantics were
> lambda-calculus-and-nothing-more. This can be contrasted with ML where the
> lambda calculus is augmented with an imperative language that isn't
> functional or a lambda calculus. Part of the problem with making purity
> about effects rather than semantics is the terrible imprecision confuses
> new people. They'll often misunderstand it as, "Haskell programs can't
> perform effects" or they'll think it means stuff in "IO" isn't pure - which
> is false. We benefit from having a pure functionalal programming language
> _especially_ in programs that emit effects. Gabriel Gonzalez has a nice
> article demonstrating some of this:
> http://www.haskellforall.com/2015/03/algebraic-side-effects.html
>
> When I want to talk about effects, I say "effect". When I want to say
> something that doesn't emit effects, I say "effect-free" and when it does,
> "effectful". Sometimes I'll say "in IO" for the latter as well, where "in
> IO" can be any type that has IO in the outermost position of the final
> return type.


------------------------------

Message: 4
Date: Sun, 13 Dec 2015 03:29:24 +0700
From: "Lim H." <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Trouble understanding the type of
        sequence        [Just, Just]
Message-ID:
        <calku0y0by5o+w4ktnoka+r_br--odzelyrpv342u_9d7pfv...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi everyone,

Sorry if this email disturbs you. I haven't used a developer's mailing list
before so I'm not sure if I'm violating any etiquette. If I do, please
excuse me.

I'm trying to understand the type of sequence [Just, Just]. I can understand
 sequence [Just 1, Just 2] :: Num a => Maybe [a]

because when looking at the type of sequence

sequence :: (Monad m, Traversable t) => t (m a) -> m (t a)

it is clear that this function takes a collection of monadic values and
return a single monadic value of the collection. Thus, when we call sequence
[Just 1, Just 2] we should get back a Just of [1,2]. Following that train
of thoughts, shouldn't sequence [Just, Just] return a single Just?
Here is the corresponding SO question

http://stackoverflow.com/questions/34244574/trouble-understanding-the-type-of-sequence-just-just

Lim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151213/ab5dac70/attachment.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of Beginners Digest, Vol 90, Issue 23
*****************************************

Reply via email to