Ad
  • Default User Avatar

    modified (with something else)

  • Custom User Avatar

    Sorry, forgot to mention that if two hands are equal, first hand should be returned

  • Custom User Avatar

    betterHand function returns a Hand, so it is not clear what to do if hands are equal.

  • Custom User Avatar

    Well, in this kata you don't need to use maps or sets of hands. I used Ord instance to emphasize that one need to compare hands

    However, I changed kata so now it doesn't requires writing an Ord Hand

  • Custom User Avatar

    All fixed. Marked as resolved.

  • Custom User Avatar

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

  • Custom User Avatar

    Good call, I missed that on the edit. Fixed now!

  • Custom User Avatar

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

  • Custom User Avatar

    That's what's known as a RankNType (or, in particular, a rank-2 type). Concrete information on it is a little difficult to come by, but you can read it straightforwardly: a value of the type forall r h . Language => r h a is one which is valid for all choices of r and h such that r instantiates Language.

    What that ultimately means is two-fold:

    1. We must construct our values using only the methods in the Language typeclass. These methods apply for all choices of r and thus do not fix us into using any particular choice of instantiating type. In other words, Terms must be built using only the basis of functions from Language and nothing more.

    2. Terms cannot rely on a particular choice of h. What this means is that the term itself must ultimately be some combination of calls to methods of Language such that the final h is unconstrained. We can see these constraints being lifted in calls to before and lambda, for instance. In terms of the language itself, this demands that Terms are "closed", i.e. they do not refer to unbound variables.

    So, ultimately Term is a clever trick which allows us to ensure that values are built using only the methods in Language and are closed.

  • Custom User Avatar

    It's not in the spec. I don't test for what you should do in that case; I don't think you should worry too hard.