Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-22 16:19:39 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2020-11-22 16:20:11 <ski> > let example 7 = [7]; example _ = [] in fromMaybe [] (asumMap ((\xs -> if null xs then Nothing else Just xs) . example) [1 .. 10])
2020-11-22 16:20:16 <lambdabot> [7]
2020-11-22 16:20:17 <ski> > let example 7 = [7]; example _ = [] in fromMaybe [] (asumMap ((\xs -> if null xs then Nothing else Just xs) . example) [1 .. 5])
2020-11-22 16:20:21 <lambdabot> []
2020-11-22 16:20:27 <siwica> merijn: Yeah, I was told so two years ago, but never really listened, unfortunately :)
2020-11-22 16:20:32 <ski> Feuermagier ^
2020-11-22 16:20:40 <maerwald> merijn: yes, but in the end... the problems I have with language linters etc since the rise of LSP have doubled as compared to the era before
2020-11-22 16:21:00 × son0p quits (~son0p@181.136.122.143) (Quit: leaving)
2020-11-22 16:21:02 <merijn> maerwald: I don't really have any issues, tbh
2020-11-22 16:21:11 <merijn> Depends on the language, I suppose
2020-11-22 16:21:19 × geekosaur quits (ac3a8c23@172.58.140.35) (Ping timeout: 245 seconds)
2020-11-22 16:21:30 <Feuermagier> ski, <B
2020-11-22 16:21:33 × alp quits (~alp@2a01:e0a:58b:4920:bd6e:5194:b82b:da55) (Ping timeout: 272 seconds)
2020-11-22 16:21:36 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 240 seconds)
2020-11-22 16:21:44 <ski> > let example 7 = 7; example _ = 0 in fromMaybe 0 (asumMap ((\x -> if x == 0 then Nothing else Just x) . example) [1 .. 10])
2020-11-22 16:21:47 <lambdabot> 7
2020-11-22 16:21:48 <ski> > let example 7 = 7; example _ = 0 in fromMaybe 0 (asumMap ((\x -> if x == 0 then Nothing else Just x) . example) [1 .. 5])
2020-11-22 16:21:50 <lambdabot> 0
2020-11-22 16:21:51 <maerwald> I tried LSP over the years again and again (for multiple languages) and in the end I just disabled it. I end up spending more time on the tooling than on coding when I use it
2020-11-22 16:22:15 jonatanb joins (jonatanb@gateway/vpn/protonvpn/jonatanb)
2020-11-22 16:23:01 × mananamenos quits (~mananamen@84.122.202.215.dyn.user.ono.com) (Read error: Connection reset by peer)
2020-11-22 16:24:42 <ski> Feuermagier : `asumMap' encodes "try one thing after another". used with `Maybe', it'll abort on the first successful try
2020-11-22 16:25:10 <Feuermagier> ski, it is exactly what I need, but what package is that from?
2020-11-22 16:26:06 Tops2 joins (~Tobias@dyndsl-095-033-027-066.ewe-ip-backbone.de)
2020-11-22 16:29:27 <dminuoso> ski: Does the invariance of m have any impact? I mean in case of `ContT m a`, it's also invariant in m.
2020-11-22 16:30:10 Fractalis joins (~Fractalis@2601:987:280:8d40:eda9:f9e1:2072:cea7)
2020-11-22 16:31:50 jlamothe joins (~jlamothe@198.251.55.207)
2020-11-22 16:32:09 <Feuermagier> ski, found the package. How do you even find these functions?
2020-11-22 16:32:52 <hekkaidekapus> @hoogle asumMap
2020-11-22 16:32:53 <lambdabot> Relude.Foldable.Fold asumMap :: forall b m f a . (Foldable f, Alternative m) => (a -> m b) -> f a -> m b
2020-11-22 16:33:24 <hekkaidekapus> But the one ski used is defined a few lines above.
2020-11-22 16:33:33 <hekkaidekapus> (In lambdabot)
2020-11-22 16:34:33 <hekkaidekapus> So, best to scroll up (again!) and take another look at ski’s code :d
2020-11-22 16:34:44 <Feuermagier> is there something like a fromJust with expectOrElse?
2020-11-22 16:35:30 <ski> Feuermagier : hm, i guess <https://hackage.haskell.org/package/relude-0.7.0.0/docs/Relude-Foldable-Fold.html#v:asumMap>. but it's also available as <https://hackage.haskell.org/package/fused-effects-1.1.0.0/docs/Control-Effect-NonDet.html#v:foldMapA> and as (in deprecated `util') <https://hackage.haskell.org/package/util-0.1.17.1/docs/Util.html#v:altMap>
2020-11-22 16:36:09 <ski> (also, <https://hackage.haskell.org/package/relude/docs/Relude-Foldable-Fold.html#v:foldMapA>,<https://hackage.haskell.org/package/util/docs/Util.html#v:foldMapA> does something different)
2020-11-22 16:37:34 <hekkaidekapus> @where hoogle
2020-11-22 16:37:34 <lambdabot> http://haskell.org/hoogle http://hoogle.haskell.org http://fpcomplete.com/hoogle – See also Hayoo, which searches more packages: http://hayoo.fh-wedel.de/
2020-11-22 16:38:17 <ski> Feuermagier : "How do you even find these functions?" -- well, it's a combinator which i've found myself wishing was defined in `Control.Applicative' or `Data.Monoid' or something, already. i hoogled around a little bit to see what people had called it, and decided i probably liked the `asumMap' name most
2020-11-22 16:38:25 × jonatanb quits (jonatanb@gateway/vpn/protonvpn/jonatanb) (Ping timeout: 240 seconds)
2020-11-22 16:38:34 <hekkaidekapus> Feuermagier: Use hoogle (the second URL in ^) to search for exact names or type signatures.
2020-11-22 16:38:52 dcoutts_ joins (~duncan@33.14.75.194.dyn.plus.net)
2020-11-22 16:39:10 <hekkaidekapus> You can also build it locally or talk to lambdabot.
2020-11-22 16:39:22 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2020-11-22 16:39:24 <hekkaidekapus> @hoogle (Foldable f, Alternative m) => (a -> m b) -> f a -> m b
2020-11-22 16:39:25 <lambdabot> Util altMap :: (Alternative p, Foldable f) => (a -> p b) -> f a -> p b
2020-11-22 16:39:25 <lambdabot> Relude.Foldable.Fold asumMap :: forall b m f a . (Foldable f, Alternative m) => (a -> m b) -> f a -> m b
2020-11-22 16:39:25 <lambdabot> Control.Effect.NonDet foldMapA :: (Foldable t, Alternative m) => (a -> m b) -> t a -> m b
2020-11-22 16:40:14 emfipp joins (~emfipp@unaffiliated/mjkr)
2020-11-22 16:40:44 <ski> dminuoso : `ExceptT e' is an `MFunctor', but `ContT o' isn't. the CPS version of `ExceptT e' above can't be, either. so it would fail a "drop-in replacement" test, if you care about `mmorph' stuff
2020-11-22 16:41:49 <Feuermagier> ski, can you paste again how you defined that function?
2020-11-22 16:41:58 conal joins (~conal@198.8.81.205)
2020-11-22 16:42:05 <ski> <ski> @let asumMap :: (Foldable t,Alternative i) => (a -> i b) -> (t a -> i b); asumMap = (getAlt .) . foldMap . (Alt .)
2020-11-22 16:42:52 <ski> that uses `Alt' from `Data.Monoid'
2020-11-22 16:43:10 <Feuermagier> interesting. thx!
2020-11-22 16:43:41 <ski> @hoogle (b -> m c) -> (a,b) -> m (a,c)
2020-11-22 16:43:42 <lambdabot> Data.Tuple.Extra secondM :: Functor m => (b -> m b') -> (a, b) -> m (a, b')
2020-11-22 16:43:42 <lambdabot> Extra secondM :: Functor m => (b -> m b') -> (a, b) -> m (a, b')
2020-11-22 16:43:42 <lambdabot> Control.Functor.HT mapSnd :: Functor f => (b -> f c) -> (a, b) -> f (a, c)
2020-11-22 16:45:22 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2020-11-22 16:45:38 × siwica quits (~user@p200300f6171ea70091500a7781251611.dip0.t-ipconnect.de) (Ping timeout: 264 seconds)
2020-11-22 16:46:29 <ski> `\(i,x) -> (i,) <$> p x' from `findIndexElem' above could be the pointless `uncurry ((. p) . fmap . (,))', or simply `secondM p'
2020-11-22 16:46:50 shailangsa joins (~shailangs@host86-186-177-155.range86-186.btcentralplus.com)
2020-11-22 16:46:53 × sdrodge quits (~sdrodge@unaffiliated/sdrodge) (Ping timeout: 272 seconds)
2020-11-22 16:47:02 <Feuermagier> ski, where is that "Alternative" from?
2020-11-22 16:47:50 <Feuermagier> the first result on hoogle is from quickcheck
2020-11-22 16:47:56 <ski> (.. but i figured i'd preferably not make it pointless to that extent, in my definitions above, in the interest of it being more intelligible)
2020-11-22 16:48:04 <ski> @index Alternative
2020-11-22 16:48:04 <lambdabot> Control.Applicative
2020-11-22 16:48:55 mananamenos joins (~mananamen@84.122.202.215.dyn.user.ono.com)
2020-11-22 16:48:56 × conal quits (~conal@198.8.81.205) (Quit: Computer has gone to sleep.)
2020-11-22 16:49:40 <ski> dminuoso : .. hmm, i wonder whether (co)yonedaing it would help with keeping it covariant
2020-11-22 16:49:52 <Feuermagier> @index Alt
2020-11-22 16:49:52 <lambdabot> Data.Monoid
2020-11-22 16:50:25 <ski> (`@index' has a limited database, iirc. but it can sometimes be useful)
2020-11-22 16:50:33 tomsmeding (hmm, 'yonedaing')
2020-11-22 16:51:08 × machinedgod quits (~machinedg@24.105.81.50) (Ping timeout: 260 seconds)
2020-11-22 16:52:44 × mananamenos quits (~mananamen@84.122.202.215.dyn.user.ono.com) (Read error: Connection reset by peer)
2020-11-22 16:53:20 <Feuermagier> ski, I have some kind of bug with the import of "Alt": i do "import Data.Monoid (getAlt, Alt)", but I get: * Data constructor not in scope: Alt :: i b -> Alt i b
2020-11-22 16:53:20 <Feuermagier> * Perhaps you want to add `Alt' to the import list in the import of
2020-11-22 16:53:20 <Feuermagier> `Data.Monoid'
2020-11-22 16:53:44 <tomsmeding> import Alt(..)
2020-11-22 16:54:01 <tomsmeding> meaning write "import Data.Monoid (getAlt, Alt(..))"
2020-11-22 16:54:19 <Feuermagier> oh, thx! - what does that syntax mean?
2020-11-22 16:54:22 <ski> or `Alt (Alt,getAlt)' (or `Alt (..)')
2020-11-22 16:54:25 <tomsmeding> as you wrote it, the "Alt" there is the _type_ Alt; appending (..) also imports the constructors of the type
2020-11-22 16:54:55 <tomsmeding> which you can indeed also list individually as ski did
2020-11-22 16:55:05 <tomsmeding> (well, constructors and record accessor functions)
2020-11-22 16:56:00 <ski> (same thing is used to import a type class, with methods)
2020-11-22 16:56:02 chaosmasttter joins (~chaosmast@p200300c4a72cf801dd23ca148139a2b5.dip0.t-ipconnect.de)
2020-11-22 16:56:51 hekkaidekapus whispers, “Punning is a misfeature” but is not ready for a flamewar ;)
2020-11-22 16:57:09 <ski> newtype ExceptT e m a = MkExceptT (forall n o. Monad n => (forall x. m x -> n x) -> (e -> n o) -> (a -> n o) -> n o) -- dminuoso, something like this. (haven't checked whether that `Monad m' is required)
2020-11-22 16:57:41 ski doesn't like naming the data constructor the same as the type constructor, fwiw ..
2020-11-22 16:58:07 <hekkaidekapus> Ah, I’m not that alone :D
2020-11-22 16:58:56 <ski> i tend to use `data Foo = MkFoo ...'. iirc monochrom has suggested `FooOf'
2020-11-22 16:59:25 <hekkaidekapus> Prefix vs Suffix.
2020-11-22 16:59:52 conal joins (~conal@198.8.81.205)
2020-11-22 16:59:53 <ski> (also `unFoo'/`runFoo'/`getFoo')
2020-11-22 17:00:02 <hekkaidekapus> The former is better for grepping, I guess. I usually use the latter.

All times are in UTC.