r/haskell • u/davidchristiansen • Jul 16 '14
Idris 0.9.14 released, with updated JavaScript backend, quasiquotes, and lots of internal cleanups and improvements
http://www.idris-lang.org/idris-0-9-14-released/2
u/Axman6 Jul 17 '14 edited Jul 17 '14
Looking through the tutorial, on page 24, 4.5, isn't the definition of Ord for Nat backwards here? I would have assumed that
Z `compare` S nwould be LT not GT; zero is less than the successor of n. I feel it should be:
instance [myord] Ord Nat where
compare Z (S n) = LT
compare (S n) Z = GT
compare Z Z = EQ
compare (S x) (S y) = compare @{myord} x yEdit: (keeping previous comment so others might find it if they're also confused) I read "This declares an instance as normal, but with an explicit name, myord." to mean that this is the normal definition of Ord for Nat; to avoid confusion I feel it should point out here that this defines a reverse ordering, rather than leaving it implicit. Had me stuck for about 5 minutes trying to make sure It was wrong (or, right in this context).
3
u/edwinb Jul 17 '14
Yes, that's the whole point of a named instance (see the '[myord]') - it's to allow an alternative to the default instance, in this case to order things backwards.
However, we've decided they're a bad idea for various other reasons (confluence, coherence, ugliness, etc...), and nobody uses them anyway, so we'll probably deprecate them in the next version.
2
u/Axman6 Jul 18 '14 edited Jul 21 '14
Sure, my point was only that it's not made clear that you intended to make a backwards instance early enough (perhaps renaming it [reverseNat] or something).
1
u/shaleh Jul 17 '14
Tutorial comments:
Section 5.3 on parameterised blocks It would help to be clear that the parameters are added to be functions first, then the parameters defined in the function call are applied.
Section 7.2 confused me as a Haskeller. How is
evenoroddbeing used in the guard statement? The pattern match on(j + j)or(S (j + j))looks to be sufficient.filterneeds a with statement because it returns a pair rather than a simple list right? The with block moves the unpacking of the pair up out of the function definition, right?Page 38 ends saying it is using a function from the prelude. Is
plusSuccRightSuccsupposed to be already defined? Or is it meaning the use ofsyma paragraph or so later?