6 kyu
Interpolation Phalanx
130tel
Loading description...
Interpreters
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
It would be nice if the declaration of
interp
was changed tointerp :: (Name -> Maybe String) -> Phalanx -> Maybe String
as the current one suggests that it receives a function(Name -> Maybe String)
and returns another function(Phalanx -> Maybe String)
.which is true with and without the parentheses because of Haskell's autocurrying. But I agree that the parentheses should be omitted as they do nothing.
Needs random tests
( Haskell )
needs upgrade to
GHC 8.8.x
That means splitting the
instance Monoid
intoinstance Semigroup
andinstance Monoid
(mappend
does not seem to be futureproof, so just additionally defininginstance Semigroup where (<>) = mappend
is not an optimal solution ) and updating the description, the initial solution and the example solution.( Crikey. That's a lot of work for a kata that doesn't even have random tests. )
Done.
All existing solutions invalidated - they need a split
Monoid
instance as well.Any replies to this thread will generate a notification to me; new posts may not.
I found the intructions somewhat cryptic compared to those in
dagger
andrazor
, but once I figured out what you wanted it wasn't too bad.This comment has been hidden.
The only issues I've found are in the description: it should mention that you have to implement rep, and maybe be a little nicer on the description of interp. For such an easy kata, I would mention what the first parameter actually is (the dictionary lookup function)
Unclear instruction. You should be more specific about difference between Lookup and Literal
You can recover the meaning from the test cases. It's difficult to describe them without giving away exactly the implementation.
First it wasn't clear to me what the point was in defining
rep
andl
. Maybe some explanation that these are the "constructor functions" which can be used to build upPhalanx
could be useful. Theninterp
breaks down what we have built. I thought that the whole point was to implementinterp
and first I wondered why the rest was needed..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 likePhalanx
: the idea of a basis encoding.Some things are not clear:
Which is correct:
interp e Empty == Nothing
orinterp e Empty == Just ""
?Is it OK for
rep
to join an extraEmpty
at the end? For example:rep 2 (Literal "A") == Literal "A"
Join
Literal "A"Join
EmptyEmpty 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?It would be nice to have the typeclass definitions in the code.
Sure, I'll add them as comments.
where
missing at bothinstance
declarationsi
should bel
instead (according to a post below that should have been fixed, but it still appears this way)Thank you, found another location for
i -> l
. The missingwhere
is valid syntax when the instance definition itself is empty. These instances must be filled in before the test cases will compile.You're right. And thanks for fixing the
i
andl
.Np! Thanks for pointing out the mistake!
The function called "i" in the text and code should be named "l", since this is what the test expects.
Good call, I missed that on the edit. Fixed now!