ABI stability

27 views
Skip to first unread message

Joachim Breitner

unread,
Aug 29, 2016, 8:06:40 AM8/29/16
to codeworl...@googlegroups.com
Hi Chris,

as I am building on CodeWorld, I guess I should ask about the policy
API stability, as your commit
https://github.com/google/codeworld/commit/e2a3f8398dd260f089eccce216f77f6201d6f7a4
broke my first course (to be given Wednesday) and all my non-trivial
examples on
http://www.seas.upenn.edu/~cis194/fall16/lectures/01-intro.html
are now blank.

The reason is that I deliberately use & initially in my course, as it
is monomorphic and discoverable on the ABI. Here is the excerpt of my
lecture notes:

By now we are tired of seeing single circles. We want more! So we
need a way to draw more than one thing. So what we are looking for
is a function that takes two pictures, and combines them to one. You
should agree with me that such a function likely would have type
Picture -> Picture -> Picture.

And now we are expericing one of the advantages of a good type
system: We can search for a type! Indeed, there is only function in
the documentation that has this type

(&) :: Picture -> Picture -> Picture

This is such a good example about type-based documentation search that
it would be bad to see it gone.

(I tell them about the deprecation warning and that they should ignore
it for the first few weeks or so.)


Would it be possible to add this back to the Haskell API module?

Greetings,
Joachim


--
Joachim “nomeata” Breitner
  ma...@joachim-breitner.dehttps://www.joachim-breitner.de/
  XMPP: nom...@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: nom...@debian.org
signature.asc

Chris Smith

unread,
Aug 29, 2016, 12:23:30 PM8/29/16
to codeworl...@googlegroups.com
Sorry!  It's back now, and your page works.  I'll think about it for a bit first, but I'll likely remove the deprecation on (&) entirely, if you find it useful.  I haven't really had a lot of actual experience to inform API decisions in /haskell.  The original reason for deprecation was a combination of fears that & was too much of a hold-over from the vanilla CodeWorld and not consistent enough with Haskell style, and concerns by a few people that it conflicts with the reverse application operator defined in lens.

My policy in the past has been to deprecate things until just before a new school year starts, then remove them.  If you have any approach you would rather see, I'm all ears.  This is one thing I've always struggled with.  I hate to break student code; but at the same time, I also don't want to end up with historical warts that make the API more complex going forward (which is a big reason I moved away from Gloss as an API).  I have thought about having some kind of API compatibility levels, but again, I hesitate to make the UI complex for new students (especially at younger ages).



--
You received this message because you are subscribed to the Google Groups "codeworld-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codeworld-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to codeworld-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codeworld-discuss/1472472393.3239.11.camel%40joachim-breitner.de.
For more options, visit https://groups.google.com/d/optout.

Joachim Breitner

unread,
Aug 29, 2016, 1:13:00 PM8/29/16
to codeworl...@googlegroups.com
Hi,

thanks for the quick fix!

Removing the deprecation warning would be even nicer for my course.

The conflict with (&) from lens is a valid point. I would not mind a
different operator (as long as it is determined by wednesday). Is there
a good operator one could use instead? But I can’t think of anything
right away (most nice operators are taken by libraries).

Compatibility modules might be a way to go. There does not have to be a
UI for it: New students will want to use the default anyways, and the
help could say (without much further explanation):

My old code broke, what should I do?

Add these lines to the top of the file:

import Prelude ()
import Prelude.Compat2015

But of course managing these compat modules is a non-trivial
commitment.

Joachim


Am Montag, den 29.08.2016, 09:23 -0700 schrieb Chris Smith:
> Sorry!  It's back now, and your page works.  I'll think about it for
> a bit first, but I'll likely remove the deprecation on (&) entirely,
> if you find it useful.  I haven't really had a lot of actual
> experience to inform API decisions in /haskell.  The original reason
> for deprecation was a combination of fears that & was too much of a
> hold-over from the vanilla CodeWorld and not consistent enough with
> Haskell style, and concerns by a few people that it conflicts with
> the reverse application operator defined in lens.
>
> My policy in the past has been to deprecate things until just before
> a new school year starts, then remove them.  If you have any approach
> you would rather see, I'm all ears.  This is one thing I've always
> struggled with.  I hate to break student code; but at the same time,
> I also don't want to end up with historical warts that make the API
> more complex going forward (which is a big reason I moved away from
> Gloss as an API).  I have thought about having some kind of API
> compatibility levels, but again, I hesitate to make the UI complex
> for new students (especially at younger ages).
>
>
>
> On Mon, Aug 29, 2016 at 5:06 AM, Joachim Breitner <mail@joachim-breit
> > send an email to codeworld-disc...@googlegroups.com.
> > To post to this group, send email to codeworld-discuss@googlegroups
> > .com.
> > To view this discussion on the web visit https://groups.google.com/
> > d/msgid/codeworld-discuss/1472472393.3239.11.camel%40joachim-
> > breitner.de.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "codeworld-discuss" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to codeworld-disc...@googlegroups.com.
> To post to this group, send email to codeworld-discuss@googlegroups.c
> om.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/codeworld-discuss/CAPq5PvLiZvH8SDCJsHt7A7vvj9WEnDLmT8vP5D2-
> eamtmNqdXw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
Joachim Breitner
Post-Doctoral researcher
http://cis.upenn.edu/~joachim
signature.asc

Chris Smith

unread,
Aug 29, 2016, 9:16:29 PM8/29/16
to codeworl...@googlegroups.com
Okay, I'm un-deprecating & in codeworld-api.  Clearly, it's too late for a new operator for this school year, and anyone using CodeWorld with lens is already hiding (&), and can continue to do so.

The rest of this can wait for a later time.  I definitely want to figure out some compelling story about compatibility, but it won't be relevant again for another year.


> > To post to this group, send email to codeworld-discuss@googlegroups
> > .com.
> > To view this discussion on the web visit https://groups.google.com/
> > d/msgid/codeworld-discuss/1472472393.3239.11.camel%40joachim-
> > breitner.de.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "codeworld-discuss" group.
> To unsubscribe from this group and stop receiving emails from it,

> To post to this group, send email to codeworld-discuss@googlegroups.c
> om.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/codeworld-discuss/CAPq5PvLiZvH8SDCJsHt7A7vvj9WEnDLmT8vP5D2-
> eamtmNqdXw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
Joachim Breitner
Post-Doctoral researcher
http://cis.upenn.edu/~joachim
--
You received this message because you are subscribed to the Google Groups "codeworld-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codeworld-discuss+unsubscribe@googlegroups.com.

To post to this group, send email to codeworld-discuss@googlegroups.com.

Joachim Breitner

unread,
Aug 30, 2016, 8:51:41 AM8/30/16
to codeworl...@googlegroups.com
Hi,

thanks, works well for me!

Looking forward to teaching Haskell with CodeWorld. We’ll even grade
and give feedback the homework submissions using CodeWorld – the
student sends a link to the TA, and then the TA sends a link back with
the annotated code.

Greetings,
Joachim
> > > > send an email to codeworld-disc...@googlegroups.com
> > .
> > > > To post to this group, send email to codeworld-discuss@googlegr
> > oups
> > > > .com.
> > > > To view this discussion on the web visit https://groups.google.
> > com/
> > > > d/msgid/codeworld-discuss/1472472393.3239.11.camel%40joachim-
> > > > breitner.de.
> > > > For more options, visit https://groups.google.com/d/optout.
> > > >
> > >
> > > -- 
> > > You received this message because you are subscribed to the
> > Google
> > > Groups "codeworld-discuss" group.
> > > To unsubscribe from this group and stop receiving emails from it,
> > > send an email to codeworld-disc...@googlegroups.com.
> > > To post to this group, send email to codeworld-discuss@googlegrou
> > ps.c
> > > om.
> > > To view this discussion on the web visit https://groups.google.co
> > m/d/
> > > msgid/codeworld-discuss/CAPq5PvLiZvH8SDCJsHt7A7vvj9WEnDLmT8vP5D2-
> > > eamtmNqdXw%40mail.gmail.com.
> > > For more options, visit https://groups.google.com/d/optout.
> > --
> > Joachim Breitner
> > Post-Doctoral researcher
> > http://cis.upenn.edu/~joachim
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "codeworld-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to codeworld-disc...@googlegroups.com.
> > To post to this group, send email to codeworld-discuss@googlegroups
> > .com.
> > To view this discussion on the web visit https://groups.google.com/
> > d/msgid/codeworld-discuss/1472490768.14464.11.camel%40cis.upenn.edu
> > .
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "codeworld-discuss" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to codeworld-disc...@googlegroups.com.
> To post to this group, send email to codeworld-discuss@googlegroups.c
> om.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/codeworld-discuss/CAPq5Pv%2BJb-
> %3DdCEAb8sLe2St%3DAxeJPkqg9khLdqk0EgKDUqhK8A%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
Joachim Breitner
ma...@joachim-breitner.de
http://www.joachim-breitner.de/
signature.asc

Joachim Breitner

unread,
Aug 30, 2016, 8:55:11 AM8/30/16
to codeworl...@googlegroups.com
Hi,

also, a corresponding upload of codeworld-api to hackage would be
appreciated.

Thanks,
Joachim
> > > > > send an email to codeworld-discuss+unsubscribe@googlegroups.c
> > > > > om
> > > .
> > > >
> > > > >
> > > > > To post to this group, send email to codeworld-discuss@google
> > > > > gr
> > > oups
> > > >
> > > > >
> > > > > .com.
> > > > > To view this discussion on the web visit https://groups.googl
> > > > > e.
> > > com/
> > > >
> > > > >
> > > > > d/msgid/codeworld-discuss/1472472393.3239.11.camel%40joachim-
> > > > > breitner.de.
> > > > > For more options, visit https://groups.google.com/d/optout.
> > > > >
> > > >
> > > > -- 
> > > > You received this message because you are subscribed to the
> > > Google
> > > >
> > > > Groups "codeworld-discuss" group.
> > > > To unsubscribe from this group and stop receiving emails from
> > > > it,
> > > > send an email to codeworld-disc...@googlegroups.com
> > > > .
> > > > To post to this group, send email to codeworld-discuss@googlegr
> > > > ou
> > > discuss/1472490768.14464.11.camel%40cis.upenn.edu
> > > .
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> > -- 
> > You received this message because you are subscribed to the Google
> > Groups "codeworld-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to codeworld-disc...@googlegroups.com.
> > To post to this group, send email to codeworld-discuss@googlegroups
> > .c
> > om.
> > To view this discussion on the web visit https://groups.google.com/
> > d/
> > msgid/codeworld-discuss/CAPq5Pv%2BJb-
> > %3DdCEAb8sLe2St%3DAxeJPkqg9khLdqk0EgKDUqhK8A%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> -- 
> Joachim Breitner
>   ma...@joachim-breitner.de
>   http://www.joachim-breitner.de/
>
signature.asc

Chris Smith

unread,
Aug 30, 2016, 11:20:25 AM8/30/16
to codeworl...@googlegroups.com
Done.  0.2.0.0 is the current hackage release now.


> > > > .
> > > > To post to this group, send email to codeworld-discuss@googlegr
> > > > ou
> > > ps.c
> > > >
> > > > om.
> > > > To view this discussion on the web visit https://groups.google.
> > > > co
> > > m/d/
> > > >
> > > > msgid/codeworld-
> > > > discuss/CAPq5PvLiZvH8SDCJsHt7A7vvj9WEnDLmT8vP5D2-
> > > > eamtmNqdXw%40mail.gmail.com.
> > > > For more options, visit https://groups.google.com/d/optout.
> > > --
> > > Joachim Breitner
> > > Post-Doctoral researcher
> > > http://cis.upenn.edu/~joachim
> > >
> > > --
> > > You received this message because you are subscribed to the
> > > Google
> > > Groups "codeworld-discuss" group.
> > > To unsubscribe from this group and stop receiving emails from it,

> > > To post to this group, send email to codeworld-discuss@googlegrou
> > > ps
> > > .com.
> > > To view this discussion on the web visit https://groups.google.co
> > > m/
> > > d/msgid/codeworld-
> > > discuss/1472490768.14464.11.camel%40cis.upenn.edu
> > > .
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> > -- 
> > You received this message because you are subscribed to the Google
> > Groups "codeworld-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > To post to this group, send email to codeworld-discuss@googlegroups
> > .c
> > om.
> > To view this discussion on the web visit https://groups.google.com/
> > d/
> > msgid/codeworld-discuss/CAPq5Pv%2BJb-
> > %3DdCEAb8sLe2St%3DAxeJPkqg9khLdqk0EgKDUqhK8A%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> -- 
> Joachim Breitner
>   ma...@joachim-breitner.de
>   http://www.joachim-breitner.de/
>
--
Joachim “nomeata” Breitner
  ma...@joachim-breitner.dehttps://www.joachim-breitner.de/
  XMPP: nom...@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: nom...@debian.org

--
You received this message because you are subscribed to the Google Groups "codeworld-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codeworld-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to codeworld-discuss@googlegroups.com.

mehryar Mansoor

unread,
Nov 14, 2016, 6:44:38 PM11/14/16
to codeworld-discuss
Thanks to Chris and Joachim, I'm having a lot of fun learning Haskell!
Previously I was bogged down with all these abstract terminologies and concepts. I think I have about 6 books on Haskell, but it was Joachim's course notes that finally made me understand the Monad.
And code-world (which I didn't know about until I started reading Joachim's course notes) injected much needed fun in playing with Haskell.
Im currently trying to see if I can translate the examples from Daniel Shiffman's "The Nature of Code" book into code-world.

I did have a question about the Haskell API.
the Haskell API notes:
simulationOf :: world -> (Double -> world -> world) -> (world -> Picture) -> IO ()


but when I convert the "Your first simulation example" from the general code-world documentation from:
main            = simulationOf(initial, step, draw)
initial(rs)     = (5,0)
step((x,y), dt) = (x - y*dt, y + x*dt)
draw(x,y)       = translated(rectangle(1,1), x, y)

to:

main            = simulationOf initial step draw
initial rs        = (5.0, 0.0)
step dt (x, y) = (x - y*dt, y + x*dt)
draw (x,y)     = translated x y (rectangle 1 1)

I get a type error:

    Couldn't match type ‘(Double, Double)’
                   with ‘t0 -> (Double, Double)’
    Expected type: Double
                   -> (t0 -> (Double, Double)) -> t0 -> (Double, Double)
      Actual type: Double -> (Double, Double) -> (Double, Double)
    In the second argument of ‘simulationOf’, namely ‘step’
    In the expression: simulationOf initial step draw

And I can't figure out from the API documentation what's wrong with my step function or how to fix it.

Thanks again to both of you! Learning Haskell is fun again!

cheers,
Mehryar

Chris Smith

unread,
Nov 14, 2016, 6:56:51 PM11/14/16
to codeworl...@googlegroups.com
Hi!  Thank you for the question.

The issue here (which, granted, is not producing the greatest of error messages) is that the initial state for a simulation doesn't take a parameter in Haskell.  So you just want "initial = (5,0)"

More details: The reason for that parameter in the original CodeWorld API is that without I/O combinators, there's no way to get random numbers in a program.  So instead, each simulation is given an infinite stream of random numbers to draw from.  But in the Haskell API, you don't need this anyway.  If you did want random numbers, you could just use newStdGen from System.Random to grab a generator before using simulationOf, and store that in your state instead.  Like this:

    main = do
        gen <- newStdGen
        simulationOf (initial gen) step draw
    initial gen = ...

Does that make sense?

--
You received this message because you are subscribed to the Google Groups "codeworld-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codeworld-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to codeworld-discuss@googlegroups.com.

Chris Smith

unread,
Nov 14, 2016, 7:00:04 PM11/14/16
to codeworl...@googlegroups.com
To follow up, the reason the error message is so confusing is that you are allowed to use whatever type you like for the state.  So when initial was a function, the compiler was fine with that.  It just decided that your state type happens to be a function in this program.  It didn't run into problems until you wrote step, which suddenly was expecting a tuple instead of a function for the state.  Same with draw.  So your error messages showed up on step and draw, even though they weren't the problem.  The problem was initial, which led the compiler to be wrong about the type of your state, and set it up to fail later!

That was a tricky one.  It stumped me at first, too.

meh...@gmail.com

unread,
Nov 14, 2016, 7:06:08 PM11/14/16
to codeworl...@googlegroups.com
Ah, makes complete sense now. Thanks so much for the fast response and detailed explanation! 

cheers,
Mehryar

Reply all
Reply to author
Forward
0 new messages