7 kyu

functions $$$ of $$ multiple $ arguments

Description
Loading description...
Algorithms
View
AllIssuesQuestions1SuggestionsShow Resolved
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    I'm passing sample tests, but on submit I get the error below. What's going on?

    test/FunctionApplicationSpec.hs:20:5: error:
        • No instance for (Show (b0 -> c0))
            arising from a use of ‘shouldBe’
            (maybe you haven't applied a function to enough arguments?)
        • In a stmt of a 'do' block:
            (id $$ (+ 2) $$ (+ 2) $$ (+ 2) $$ 0) `shouldBe` 6
          In the second argument of ‘($)’, namely
            ‘do (id $ (+ 1) $ (+ 1) $ (+ 1) $ 0) `shouldBe` 3
                (id $$ (+ 2) $$ (+ 2) $$ (+ 2) $$ 0) `shouldBe` 6
                (id $$$ (+ 3) $$$ (+ 3) $$$ (+ 3) $$$ 0) `shouldBe` 9’
    
    • JohanWiltink Avatar

      Tests are trying to show a function, which it can't.

      I can see your solution, but I can't see what's wrong with either your solution or the tests. I'm sorry; I'll keep looking.

    • JohanWiltink Avatar

      Apparently this is not an easy 7 after all. GHC is quite stubborn and fussy. There are ( multiple ) solutions possible, I promise, but I still can't explain just why yours shouldn't work.

      Without giving too much away, I can only say: keep it simple, as simple as possible.

    • dfhwze Avatar

      I made it as simple as I could. What I don't get is why it passes sample tests, but not test cases.

    • JohanWiltink Avatar

      I don't either. Sorry.

      It works without the type signatures. ( It can also work with simpler type signatures. ) For your implementation, the compiler pragma is unnecessary, but I don't think that's what causing the failures.

      The problem may be that nested $$s don't play nice with overly specific type signatures. ( The library $ has a rather complicated type and some unintelligible explanation for that. ) But that's a shot in the dark.

    • dfhwze Avatar

      I came close to solving it :)

      Question marked resolved by dfhwze 2 years ago
    • JohanWiltink Avatar

      You definitely had the right idea. Morally, you solved it. :]

    • dfhwze Avatar

      Well, I finally made it. Needed a complete strip down, which makes me think whether the spec is ok. ($$) should also work with less than 2 arguments etc ..

    • dfhwze Avatar

      This comment has been hidden.

    • Kacarott Avatar

      I thought those were the same O_o

      Edit: memowe's solution doesn't seem to pass actually, presumably caused by a change in version...?

    • dfhwze Avatar

      I'm beyond confused

    • JohanWiltink Avatar

      I was also absolutely convinced those are the same. I still am - submit tests are not working for me with that type signature.

    • JohanWiltink Avatar

      This comment has been hidden.

    • JohanWiltink Avatar

      If I specify such, is it reasonable to expect f $ x, f $$ x and f $$$ x to all work, in addition to f $$ x $ y and f $$$ x $$ y $ z ?

      Or should I only require multiple $s to have as least as many arguments as there are $s ?

      Also, I should probably have all the submit tests as example tests. No reason why not.

    • dfhwze Avatar

      I think if you add all the submit tests as sample tests, it would become apparent. Whether to change the description is up to you.