These are chat archives for evhub/coconut

20th
Mar 2017
Evan Hubinger
@evhub
Mar 20 2017 18:04
@hasufell If you don't like addpattern, what about
def func(xs):
    case xs:
        match []: ...
        match [x]: ...
        match xs: ...
Julian Ospald
@hasufell
Mar 20 2017 19:31
@evhub that's inside the function
when I have functions that behave fundamentally different in terms of codepath wrt input I like to see that immediately
Evan Hubinger
@evhub
Mar 20 2017 19:56

@hasufell Yeah, I agree with that, and that's what addpattern is for. So the best way to do that would be

def func([]) = ...
@addpattern(func)
def func([x]) = ...
@addpattern(func)
def func(xs) = ...

I agree that for small functions like that it can look clunky, but I'm not sure what a better way to do it would be. Thoughts?