I once used `traverse optional` combined with `catMaybes`. For example:Prelude Control.Applicative Data.Maybe> catMaybes <$> traverse optional [[1,2],[3]][[1,3],[1],[2,3],[2],[3],[]]This is totally out of order. I think a more natural output is:[[],[3],[1],[1,3],[2],[2,3]]_______________________________________________2019년 9월 1일 (일) 오후 11:23, Edward Kmett <ekmett@gmail.com>님이 작성:It would also render the combinator useless for its normal purpose.optional is used mostly to try to run a parser and to either succeed with its result (wrapped in a Just) or _failing that_ to just return Nothing and carry on.For monads like parsec, the first parse is the one that gets returned, so the definition isn't symmetric in behavior.-EdwardOn Sun, Sep 1, 2019 at 2:28 AM Dannyu NDos <ndospark320@gmail.com> wrote:The current 'one or none' definition breaks the order of elements._______________________________________________It is more Ord-friendly to define it as 'none or one'.
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries