Ad
  • Custom User Avatar

    Hints to define isoUnMaybe

    I'm writing this comment since this is the function I had the most problems defining.

    I hope these hints help someone in my situation get into the mindset necessary to solve this on their own.

    Hint 1

    DO NOT READ UNTIL YOU TRIED THE PUZZLE BY YOURSELF

    The resulting function is total, even though it uses a non-total function in the code. It's up to the developer to prove (independently) that the result is total since the type-checker can't verify it on it's own.

    Hint 2

    DO NOT READ UNTIL YOU TRIED THE PUZZLE USING HINT #1

    Consider the relationship between the value Just a that the forward function (:: Maybe a -> Maybe b) sends to Nothing and the backward function (:: Maybe b -> Maybe a). Remember that both functions are supposed to form an isomorphism. What kind of relationship would the Null spaces of either
    Given the fact that the forward (:: Maybe a -> Maybe b) and backward (:: Maybe b -> Maybe a) form an isomorphism, consider the relationship between the value (Just a) which the forward function sends to Nothing and the backward function.

    Hint 3

    DO NOT READ UNTIL YOU TRIED THE PUZZLE USING HINT #2

    You might want to look into implementing the following special case:

    newtype Foo = Foo Int 
    newtype Bar = Bar Int
    
    isoMaybeFooBar :: ISO (Maybe Foo) (Maybe Bar)
    isoMaybeFooBar = (foobar, barfoo)
      where 
      foobar (Just (Foo x)) 
       | x == 0      = Nothing
       | otherwise   = Just (Bar x)
      foobar Nothing = Just (Bar 0)
      
      barfoo = error "try to implement this"
    
    isoUnMaybeFooBar :: ISO (Maybe Foo) (Maybe Bar) -> ISO Foo Bar 
    isoUnMaybeFooBar = error "try to implement this"
    
  • Custom User Avatar

    Got this one first try, really I just had to follow whatever error message my IDE was saying ^^
    But the comments are better than for isomorphism IMO, and I know what was the mindset of the kata, so I can't complain x) and it's always satifaying to go from red to green ^^

  • Custom User Avatar

    [solved in rust]

    I did this kata by just writing the simplest code I could to make it compile, and then understand the little tricks about iso_un_option, iso_eu.
    I must say I don't really understand what's this kata supposed to teach you... I did learn stuffs though, being new to rust, I understood the concept "catpuring" closures / move + closure, which seems really useful.
    But besides that I don't really get it. Ok, if you have a bijection between A U {None} and B U {None}, then you have a bijection between A and B. But I can prove that pen & paper in 3 minutes, no need to sratch my head writing un-readable code just guided by the IDE/rust-analyser error messages...

    My conclusion is that: you should write what's the purpose of the kata in the description.
    Is it to prove some (failrly basic) isomorphisms' properties using code/type systems?
    For me, "We will walk through the definition of isomorphism and define some common isomorphisms" is too vague, and personnaly it generates frustration. Please write of few more lines of description.

    Also, the comment "Going the other way is hard (and is generally impossible) ... You need this to prove some cases are impossible." felt fairly confusing. Something like "Nothing forbids Some(a) to map to None" would have been much clearer (without give it away).
    Same for "inf + 1 = inf + 0", you need to be somewhat aware of specific ways of "building integers" to understand this, which feels a bit sad for people who don't.

    Sorry to be harsh, I know you've spent time on this.

    Now that I have understand the mindset, I might try the follonw ones, and even enjoy it. But that would have helped to get that from the description.

  • Custom User Avatar

    Marking Resolved as of Jauttaro Coudjau.

  • Custom User Avatar

    this is now untrue, isomorphism is available :) https://www.codewars.com/kata/isomorphism

    Should be marked as resolved

  • Custom User Avatar

    I can't see your comment, it's hidden

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Great and rewarding challenge, so much fun

  • Custom User Avatar

    The Rust translation of this kata depends on having solved the Rust version of the Isomorphism kata, which no longer exists.

  • Custom User Avatar

    Hi I was wondering, are there any missing exercises/functions for the rust type?

  • Custom User Avatar

    This is smart but extremely slow!

  • Custom User Avatar

    A bijection is an isomorphism in the category of sets, meaning that it is just an invertible one-to-one mapping between two sets.Many categories can be thought of as sets with additional structure (e.g. groups, rings, differentiable functions etc.) and an isomorphism requires the structure of the category to be preserved. For example if you are mapping in the category of groups, then you need to map the identity element of the first group to the identity of the second group and you need to preserve the group law so that f(a*b) = f(a).f(b) where * is the group operation of the first group and . is the operation in the second group.

    The fact that there is a hint in the instructions to look at the wikipedia page for a bijection rather than the category theory definition of an isomorphism is actually a fairly subtle clue how to solve one of the parts of the kata which can only be solved by possibly breaking the isomorphism structure.

  • Custom User Avatar

    this stuff seems to be broken, not sure if it's currently solvable. TraceshowID doesn't show any evaluation.

  • Custom User Avatar

    You can encode maybe as well

  • Loading more items...