Sixth assignment now available

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Sixth assignment now available

Beitrag von sewe »

The sixth assignment (6 Tasks, 10 points overall) is now available: https://cage.st.informatik.tu-darmstadt ... 012-05-25/. Please note: This assignment consists of two parts/files. Additionally, there is an example of a simple interpreter in monadic style which should be helpful when solving task 6: https://cage.st.informatik.tu-darmstadt ... adic-ae.hs.

This assignment is due on Thursday, 31 May 2012, 23:59.

That being said, there has been a technical problem with the repository. If you are unlucky, you may need to check out the whole repo again: svn co https://cage.st.informatik.tu-darmstadt.de/2012/copl. Sorry about that. :-(

Benutzeravatar
olg
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 297
Registriert: 1. Okt 2008 19:24

Re: Sixth assignment now available

Beitrag von olg »

Is the return type of "runWithCounter" in the assignment-pt2 wrong, or am I missing something?

Test5 expects the return type of runWithCounter to be (a, Int), but the declaration suggests to return only a?

Code: Alles auswählen

runWithCounter :: State Int a -> a
If I'm changing the return type of runWithCounter to (a, Int), test5 succeeds.


Additionally, i'm having some difficulties finding a proper implementation for myseq. Can you give me a small hint? I'm currently trying to force the evaluation for each member of 'Value' by calculating on the resulting value, without actually returning the result of that operation. Is there an easier way?
"To Perl, or not to Perl, that is the kvetching." ~Larry Wall

Osterlaus
BSc Spammer
BSc Spammer
Beiträge: 1263
Registriert: 23. Aug 2007 12:46
Wohnort: DA

Re: Sixth assignment now available

Beitrag von Osterlaus »

I'm stuck at another point: as far as I can see, the method incr only returns a state. How does it know about the counter it should increment...???

DanielSchoepe
Mausschubser
Mausschubser
Beiträge: 49
Registriert: 28. Sep 2009 11:39

Re: Sixth assignment now available

Beitrag von DanielSchoepe »

olg hat geschrieben:Test5 expects the return type of runWithCounter to be (a, Int), but the declaration suggests to return only a?
Is it possible that you accidentally changed the type of runWithCounter yourself? It has the result type (a, Int) here.
Osterlaus hat geschrieben:I'm stuck at another point: as far as I can see, the method incr only returns a state. How does it know about the counter it should increment...???
Take another look at the definition of the State data type. Think about how you can construct a value of that type.

Benutzeravatar
olg
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 297
Registriert: 1. Okt 2008 19:24

Re: Sixth assignment now available

Beitrag von olg »

DanielSchoepe hat geschrieben:
olg hat geschrieben:Test5 expects the return type of runWithCounter to be (a, Int), but the declaration suggests to return only a?
Is it possible that you accidentally changed the type of runWithCounter yourself? It has the result type (a, Int) here.
It seems like I have. I've checked the exercises, and the result type is correct. Sorry for the confusion.
"To Perl, or not to Perl, that is the kvetching." ~Larry Wall

Osterlaus
BSc Spammer
BSc Spammer
Beiträge: 1263
Registriert: 23. Aug 2007 12:46
Wohnort: DA

Re: Sixth assignment now available

Beitrag von Osterlaus »

DanielSchoepe hat geschrieben:
Osterlaus hat geschrieben:I'm stuck at another point: as far as I can see, the method incr only returns a state. How does it know about the counter it should increment...???
Take another look at the definition of the State data type. Think about how you can construct a value of that type.
Sorry, but that doesn't help me any further...

Osterlaus
BSc Spammer
BSc Spammer
Beiträge: 1263
Registriert: 23. Aug 2007 12:46
Wohnort: DA

Re: Sixth assignment now available

Beitrag von Osterlaus »

One more question. How can we be sure to have the eager evaluation done properly? We could also throw the error if the lookup fails, without any transition to eager evaluation.

I'm a bit surprised by the current assignment. Besides the first two tasks, that were not that difficult, I run into dead ends at any task :(

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Re: Sixth assignment now available

Beitrag von sewe »

olg hat geschrieben:Additionally, i'm having some difficulties finding a proper implementation for myseq. Can you give me a small hint? I'm currently trying to force the evaluation for each member of 'Value' by calculating on the resulting value, without actually returning the result of that operation. Is there an easier way?
Here's a hint: Your current implementation is a good first step, but already goes too far. Why do you need to calculate stuff with the Int wrapped inside a NumV? You only need to force Haskell to "materialize" said Int. How can you do that? (Hint works analogously for ClosureV, but "calculate stuff" makes more sense for a NumV ;-))

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Re: Sixth assignment now available

Beitrag von sewe »

Osterlaus hat geschrieben: One more question. How can we be sure to have the eager evaluation done properly? We could also throw the error if the lookup fails, without any transition to eager evaluation.
The point is that with lazy evaluation you may not even get to the point where the lookup is performed. Maybe if you could post some code for the interpreter here, I could construct a counterexample, i.e., a program where the error call won't be reached due to laziness.
Osterlaus hat geschrieben:I'm a bit surprised by the current assignment. Besides the first two tasks, that were not that difficult, I run into dead ends at any task :(
Can you turn this into a more specific question please?

Anyway, here are some more generic hints:
  • For task 3, review the lecture's slides on strictness points again and first think where those points should be in the interpreter before writing any code.
  • For task 5, mentally expand the type (State) to its definition; if you are new to monads looking under the hood, i.e., thinking in terms of s -> (a, s) is a good idea.
  • For task 6, try to convert the interpreter into monadic style first (without using incr; just use the Identity monad like in monadic-ae.hs.) Only then add the calls to incr.
Hope this helps a bit.

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Re: Sixth assignment now available

Beitrag von sewe »

The model solutions are now in the SVN repository: https://cage.st.informatik.tu-darmstadt ... 012-05-25/.

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Re: Sixth assignment now available

Beitrag von sewe »

(Finally), I marked the sixth assignment. :-)

The points.txts are at the usual place in the SVN repository.

Antworten

Zurück zu „Archiv“