Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Just hid it myself as well. Not sure what changed---perhaps an updated version of Hspec. It appears to work now, let me know if the situation changes.

  • Custom User Avatar

    I added a paragraph which I hope helps clarify a bit. I'm glad you enjoyed the kata! I probably will make more in time :)

  • Custom User Avatar

    There's a lot to analyze, to be completely fair. i would suggest reading some material on more basic formulations of lenses to see better how this one comes to be.

    But that said, type-tetris level understanding is where I personally began understanding this material as well, so it's a meaningful first step.

  • Custom User Avatar

    Maybe the greater question is - is newtype LengthList simple a wrapper?

    Yep! It does little more than allow us to define new instances which differ from the inner type.

    Also... is instance Ord a... defining how LengthList will respond to the functions defined by the Ord typeclass?

    Precisely.

  • Custom User Avatar

    Ah, ah! Sorry, I didn't mean to appear defensive.

    I agree that this is a good example of how types can express a fairly complete picture of semantics! It makes for a lovely example for that reason.

    And if you're not interested in the whole paper, I'd recommend Oleg's website which contains much of the same information but is more example driven.

  • Custom User Avatar

    I'm not sure what you're asking.

    Yes, this example is from the paper. If you like you can simply play type tetris and cobble the code together without understanding it.

    But if you're going to go that way then you're clearly skipping steps in understanding. I'd suggest reading the paper in earnest.

  • Custom User Avatar

    I'd definitely encourage you to keep looking. There is a much nicer way to do this still lurking :)

  • Custom User Avatar

    You can recover the meaning from the test cases. It's difficult to describe them without giving away exactly the implementation.

  • Custom User Avatar

    Added one! Thanks for the suggestion!

  • Custom User Avatar

    You're on point in noting that Nothing ought to capture things like Infinity which are represented in the Double type and pull them up to the Maybe enclosing the double.

    The trick is to note exactly when these "exceptions" could arise. In particular, the Infinity in ex3 arises when we divide 1 by 0. Since Dagger internalizes division using Divide, you'll want to focus on what happens when we call interp (Divide a b). In particular, how can you detect when b :: Dagger represents 0?

  • Custom User Avatar

    I'm intentionally a little vague around that. You can read the idea that "interp breaks down what we have built" by thinking about the tail end of its type: Phalanx -> String. If you haven't done the razor and dagger language kata yet then they hopefully build that intuition.

    The other reason I am intentionally a little vague here is because there are two ways to solve the rep bit and if you end up going down one path and then notice the other you'll be forced to consider something really interesting about DSLs/embedded languages like Phalanx: the idea of a basis encoding.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Empty should produce the empty string. Nothing is reserved for actual interpretation failures. Rep can work that way if you like, can you formulate a set of laws about the behavior of interp which prove it?

  • Custom User Avatar

    Both fixed! Thanks again

  • Loading more items...