It seems to me that Selective functors could in principle desugar more do notations than Applicatives. For example:
main = do
number <- (readMaybe :: String -> Maybe Int) <$> getLine
case number of
Just _dontuseme -> putStrLn "Yes, that's a number"
Nothing -> putStrLn "Nope, not a number"
I believe this has the same semantics as:
main = maybe (Right (Left ())) Left . (readMaybe :: String -> Maybe Int) <$> getLine
<*? (putStrLn "Yes, that's a number" *> pure (const (Right ())))
<*? (putStrLn "Nope, not a number" *> (pure id))
The latter only needs Selective.
In general, all if statements could be desugared into Selective, and case could be desugared iff the variables bound in the branches are not used in a binding way.
I've asked some of this here: https://discourse.haskell.org/t/efficient-selectivedo-and-binary-search/1657/3 but I wanted to know your opinion. I think this would be interesting, especially in situations where no efficient monads exist, e.g. some streaming approaches.
It seems to me that
Selectivefunctors could in principle desugar more do notations thanApplicatives. For example:I believe this has the same semantics as:
The latter only needs
Selective.In general, all
ifstatements could be desugared intoSelective, andcasecould be desugared iff the variables bound in the branches are not used in a binding way.I've asked some of this here: https://discourse.haskell.org/t/efficient-selectivedo-and-binary-search/1657/3 but I wanted to know your opinion. I think this would be interesting, especially in situations where no efficient monads exist, e.g. some streaming approaches.