Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
laziness, multiparametric classes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mechvel  
View profile  
 More options Jul 15 2012, 2:30 pm
From: mechvel <mech...@botik.ru>
Date: Sun, 15 Jul 2012 11:30:10 -0700 (PDT)
Local: Sun, Jul 15 2012 2:30 pm
Subject: laziness, multiparametric classes

Hello,
 I have the following beginner questions.
1. Is Idris going to have multiparametric classes?
2. May Idris have lazy evaluation?

Regards,
Sergei


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Edwin Brady  
View profile  
 More options Jul 15 2012, 2:32 pm
From: Edwin Brady <edwin.br...@gmail.com>
Date: Sun, 15 Jul 2012 19:32:06 +0100
Local: Sun, Jul 15 2012 2:32 pm
Subject: Re: [Idris] laziness, multiparametric classes
Hi,

On 15 Jul 2012, at 19:30, mechvel wrote:

> Hello,
>  I have the following beginner questions.
> 1. Is Idris going to have multiparametric classes?

It already does! Though no

> 2. May Idris have lazy evaluation?

You can use laziness annotations - you annotate function arguments with a vertical bar '|', or use the built in function lazy : a -> a.

This doesn't give you full laziness though, just means the argument isn't evaluated immediately.

Edwin.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Serge D. Mechveliani  
View profile  
 More options Jul 16 2012, 8:42 am
From: "Serge D. Mechveliani" <mech...@botik.ru>
Date: Mon, 16 Jul 2012 16:42:26 +0400
Local: Mon, Jul 16 2012 8:42 am
Subject: Re: [Idris] laziness, multiparametric classes

On Sun, Jul 15, 2012 at 07:32:06PM +0100, Edwin Brady wrote:
> [..]
> > 2. May Idris have lazy evaluation?

> You can use laziness annotations - you annotate function arguments
> with a vertical bar '|', or use the built in function lazy : a -> a.

> This doesn't give you full laziness though, just means the argument
> isn't evaluated immediately.

For example, consider the following Haskell program for a
"complicated division with remainder" for  positive integers.

-------------------------------------------------------------------
genDivRem :: Integer -> Integer -> (Integer, Integer)
                                    -- quot  rem
genDivRem n m =  cDRem 0 n
                 where
                 cDRem q r = if r < m then (q, r)
                             else          cDRem (q + (count q)) (r-m)

count :: Integer -> Integer
count n =  cn (n^6)           -- to make the first component expensive
           where
           cn n = if n < 0 then 1  else  cn (n-1)

genRem :: Integer -> Integer -> Integer
genRem n m =  snd (genDivRem n m)

genQuot :: Integer -> Integer -> Integer
genQuot n m =  fst (genDivRem n m)

main = putStr (shows (genRem 40 2) "\n")
                      -- genQuot
-------------------------------------------------------------------

I program _only_  genDivRem,  and further, use

    genDivRem n m,  snd (genDivRem n m),  fst (genDivRem m n),

depending on what it is needed.
And, for example,              genRem 40 2 =  snd (genDivRem 40 2)
works fast due to laziness.

In a _strict_ language, this approach would not do, because
snd (genDivRem m n)  will cause a great volume of unneeded computation
in the first component.
In a _strict_ language, one needs to program a separate loop for
computing the remainder only.
This approach complicates program systems.

Now, in  Idris,  how may it look a similar program and a similar usage
for   genDivRem m n  with using the laziness annotation?

Thank you for explanation,

------
Sergei
mech...@botik.ru


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »