Open Gurkenglas opened 8 years ago
Not sure where I've ever seen this idiom?
ah. i usually do flip evalState x
, things like that. (evalState
x) does look a bit silly, but flip evalState x
seems pretty mundane to me.
that being said, the only reason runStateT
has the order that it does is to be a hack using record accessors, I think:
data StateT s m a = StateT { runStateT :: s -> m (a, s) }
so you get
runStateT :: StateT s m a -> (s -> m (a, s))
for "free". I always felt like this was an abuse of record syntax, but :|
flip runState
looks pretty nice to me. in any case, having an alias for flip runState
sounds like a pretty bad sort of API bloat or fairnbairn-threshold-failing thing :/
Right about the bloat, but both flips have their place. My intuition does tell me runStateT is the correct one, because it and evalState etc. often allow eta reduction. Only sometimes the initial state is constant and I wonder.
[
This has already been proposed and there's even a patch: https://phabricator.haskell.org/D1219, https://ghc.haskell.org/trac/ghc/ticket/10843. However:
My conclusion was that support for the extension was very mixed, and that I do not think the extension makes sense without overall approval from the community. I am not planning on pushing this any further.
Those cons are stupid!
It's harder to read than the alternative.
Subjective.
Creating a language extension to get rid of a single character is overkill and unnecessary.
Overkill yes, unnecessary no - it's literally what needs to happen to get rid of that character (right?)
You can already get rid of the $ by just adding parentheses.
$ was introduced in the first place to get rid of parentheses! The preference ordering is () < $ < _.
More and more syntactic "improvements" just fragment the language.
That can be said about any syntactic improvement, and this is the way we've been left to get to the mythical Haskell'.
Although this is consistent with record syntax, record syntax without parents was a mistake originally.
If those are the same cons that were brought up here, see above.
Why do we need approval to introduce language extensions anyway, instead of me being able to import that patch like a library?
I'm not sure whether this should look this stupid and I should change my approach, or we're just missing an alias.