These are chat archives for evhub/coconut

29th
Mar 2017
Julian Ospald
@hasufell
Mar 29 2017 11:03
@evhub well, that's counter-intuitive wrt currying. How do you write that with fmap composition?
also, when I pass --mypy to coconut, it always opens the Interpreter
Julian Ospald
@hasufell
Mar 29 2017 11:15
mypy throws so many errors I don't even know where to start. Documentation on mypy is poor too
it seems one has to play around with MYPYPATH and whatnot
Julian Ospald
@hasufell
Mar 29 2017 12:18
Seems coconut doesn't play well with mypy, because it uses its own types: Invalid type "__coconut__.str
So I can't use str pretty much.
Julian Ospald
@hasufell
Mar 29 2017 12:30
And coconut converts some return statements in such a way that it ends up being a raise statement in the compiled python file, which means that mypy will wrongly validate anything as return type.
Evan Hubinger
@evhub
Mar 29 2017 19:46
@hasufell You wouldn't do that with composition, because function composition is not what you're doing there--if you were passing the result of the first function to the second function, that would be a case for function composition, but in this case you are passing the function itself to the second function, which is a case for partial application.
As for MyPy, make sure to pass --mypy last, since all arguments passed after that will be passed to MyPy. You shouldn't have to mess around with MYPYPATH, since Coconut should take care of that for you--if you are having to, that would definitely be a bug deserving of an issue. As for the str and raise (coming from TCO) incompatibilities, those are also definitely deserving of an issue. I'll try to see what I can do later this week.
Julian Ospald
@hasufell
Mar 29 2017 19:48
I can't follow wrt composition, this naturally works in haskell this way (fmap . fmap) (+1) $ [[1],[2]]
and fmap takes a function as first argument, does it not? And so does fmap .. fmap
Evan Hubinger
@evhub
Mar 29 2017 21:14
@hasufell I think the problem you're seeing is that Python has no way to reliably find the arity of a function, which means all but the last function in a function composition must be 1-ary, since all the arguments get passed to the first function, then only the result of that function is passed on to the next function.