Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-22 15:51:02 × jonatanb quits (jonatanb@gateway/vpn/protonvpn/jonatanb) (Remote host closed the connection)
2020-11-22 15:51:41 jonatanb joins (jonatanb@gateway/vpn/protonvpn/jonatanb)
2020-11-22 15:51:59 <ski> @let asumMap :: (Foldable t,Alternative i) => (a -> i b) -> (t a -> i b); asumMap = (getAlt .) . foldMap . (Alt .)
2020-11-22 15:52:01 <lambdabot> Defined.
2020-11-22 15:52:15 <ski> @let label :: (Traversable t,Enum n) => n -> t a -> t (n,a); label n = (`evalState` n) . traverse (\a -> (,a) <$> get <* modify succ)
2020-11-22 15:52:16 <lambdabot> Defined.
2020-11-22 15:52:22 × dwt quits (~dwt@c-98-200-58-177.hsd1.tx.comcast.net) (Ping timeout: 260 seconds)
2020-11-22 15:52:23 <ski> > label [2,3,5,7]
2020-11-22 15:52:26 <lambdabot> error:
2020-11-22 15:52:26 <lambdabot> Ambiguous occurrence ‘label’
2020-11-22 15:52:26 <lambdabot> It could refer to
2020-11-22 15:52:31 <ski> > L.label [2,3,5,7]
2020-11-22 15:52:33 <lambdabot> error:
2020-11-22 15:52:33 <lambdabot> • No instance for (Typeable a0)
2020-11-22 15:52:33 <lambdabot> arising from a use of ‘show_M582103790923675916012806’
2020-11-22 15:52:35 <Feuermagier> https://pastebin.com/QuDwgYk9 I want to call this function with the ints 1 to 10. If it returns something else than the empty list, I want to short-circuit return that. If I never get a result, I want to return an empty list as well. hekkaidekapus
2020-11-22 15:52:40 <ski> oh, right ..
2020-11-22 15:52:41 <merijn> ski: More efficiently implemented as "getLabel . coerce fold" ;)
2020-11-22 15:52:49 <ski> > label 0 [2,3,5,7]
2020-11-22 15:52:52 <lambdabot> error:
2020-11-22 15:52:52 <lambdabot> Ambiguous occurrence ‘label’
2020-11-22 15:52:52 <lambdabot> It could refer to
2020-11-22 15:53:10 ski sighs
2020-11-22 15:53:11 <ski> > L.label 0 [2,3,5,7]
2020-11-22 15:53:14 <lambdabot> [(0,2),(1,3),(2,5),(3,7)]
2020-11-22 15:53:20 <ski> @let findIndexElem :: Alternative i => (a -> i b) -> ([a] -> i (Int,b)); findIndexElem p = asumMap (\(i,x) -> (i,) <$> p x) . label 0
2020-11-22 15:53:22 <lambdabot> .L.hs:167:56: error:
2020-11-22 15:53:22 <lambdabot> Ambiguous occurrence ‘label’
2020-11-22 15:53:22 <lambdabot> It could refer to
2020-11-22 15:53:27 <ski> @let findIndexElem :: Alternative i => (a -> i b) -> ([a] -> i (Int,b)); findIndexElem p = asumMap (\(i,x) -> (i,) <$> p x) . L.label 0
2020-11-22 15:53:29 <lambdabot> Defined.
2020-11-22 15:53:31 <ski> > (findIndexElem . findIndexElem) (guard . (0 ==)) [[1,2,3],[4,5,0],[0,8,9]] :: Maybe (Int,(Int,()))
2020-11-22 15:53:33 <lambdabot> Just (1,(2,()))
2020-11-22 15:53:36 <ski> > (findIndexElem . findIndexElem) (guard . (0 ==)) [[1,2,3],[4,5,0],[0,8,9]] :: [] (Int,(Int,()))
2020-11-22 15:53:38 <lambdabot> [(1,(2,())),(2,(0,()))]
2020-11-22 15:54:41 <hekkaidekapus> Feuermagier: Guards work with boolean expressions.
2020-11-22 15:54:58 <merijn> hekkaidekapus: With patterns too :p
2020-11-22 15:55:03 <ski> Feuermagier : `findIndexElem' ^ is another way to do it
2020-11-22 15:55:28 <Feuermagier> hekkaidekapus, can I generate the range of indexes to call with on the fly?
2020-11-22 15:55:39 <hekkaidekapus> merijn: Ok. But that `otherwise []` is not ok :p
2020-11-22 15:55:41 <merijn> > let {foo x | Just y <- x = show y; foo _ = "Nothing" } in foo (Just 2)
2020-11-22 15:55:43 <lambdabot> "2"
2020-11-22 15:56:01 × jonatanb quits (jonatanb@gateway/vpn/protonvpn/jonatanb) (Ping timeout: 256 seconds)
2020-11-22 15:56:37 <ski> merijn : this `getLabel' is from ?
2020-11-22 15:56:52 <hekkaidekapus> Feuermagier: Generating indexes on the fly would better be done with zip.
2020-11-22 15:57:21 <merijn> ski: eh, getAlt I meant :)
2020-11-22 15:57:29 <Feuermagier> ski, i found https://codereview.stackexchange.com/questions/58954/getting-the-index-x-y-of-a-char-in-a-2d-list-in-haskell
2020-11-22 15:58:11 <hekkaidekapus> Oh, wait! Reading the backlog, I see you have been at this for a while already. And ski has already answered the ‘generate indexes’ question. :)
2020-11-22 15:58:20 <ski> merijn : oh, you meant `asumMap'/`altMap'/`foldMapA'
2020-11-22 15:58:29 <Feuermagier> hekkaidekapus, but do those short circuit?
2020-11-22 15:58:29 <merijn> yeah
2020-11-22 15:58:39 cads joins (~cads@ip-64-72-99-232.lasvegas.net)
2020-11-22 15:59:00 <ski> (i thought you meant my `label')
2020-11-22 15:59:25 <hekkaidekapus> ski: Is your findIndexElem a follow-up to an earlier convo with Feuermagier?
2020-11-22 15:59:32 <ski> yes
2020-11-22 15:59:38 <Feuermagier> yes
2020-11-22 15:59:50 <hekkaidekapus> Feuermagier: Read what ski just wrote.
2020-11-22 16:00:21 <ski> (from an hour, to an hour and a half, ago)
2020-11-22 16:00:23 <hekkaidekapus> (And ask questions if you get stuck.)
2020-11-22 16:00:43 <Feuermagier> hekkaidekapus, i have that problem with the indexes solved
2020-11-22 16:01:06 <hekkaidekapus> Feuermagier: No, take a step back and follow ski’s code.
2020-11-22 16:01:58 <ski> hekkaidekapus : i was curious about how to express a solution to the problem, in terms of composing a function with itself, in order to deal with the nested lists. (similarly to `map . map',`mapM . mapM',`mapM_ . mapM_',`zipWith . zipWith',`liftA2 . liftA2',&c.)
2020-11-22 16:02:02 elfets joins (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de)
2020-11-22 16:03:07 <ski> Feuermagier : `label n' is just a generalization of `zip [n ..]', for the fun of it. you can use plain `zip' instead, since you're dealing with lists anyway
2020-11-22 16:03:30 <hekkaidekapus> ski: heh I guess that will be a bit hard to explain given that there was a hiccup with (<$>) :p
2020-11-22 16:03:40 invaser joins (~Thunderbi@31.148.23.125)
2020-11-22 16:04:30 <Feuermagier> ski, are we still at the index-function or on my "find first valid result from function" problem? - or are they both similar in a way I miss?
2020-11-22 16:06:06 <dminuoso> Is there an ExceptT but with Cont inside?
2020-11-22 16:06:48 <dminuoso> I want to add exceptions to this monad, but with a a higher guarantee of fusion..
2020-11-22 16:07:37 <dminuoso> Or should I rather just use ContT with callCC, and hide this behind newtypes?
2020-11-22 16:08:39 <ski> Feuermagier : the former. i haven't really thought about the latter, yet
2020-11-22 16:08:55 Deide joins (~Deide@217.155.19.23)
2020-11-22 16:11:38 <ski> dminuoso : hm .. maybe something like `newtype ExceptT e m a = MkExceptT (forall o. (e -> m o) -> (a -> m o) -> m o)' ?
2020-11-22 16:11:57 <dminuoso> ski: Yeah
2020-11-22 16:12:08 ski notes that this is invariant in `m'
2020-11-22 16:12:35 siwica joins (~user@p200300f6171ea70091500a7781251611.dip0.t-ipconnect.de)
2020-11-22 16:12:37 <dminuoso> What do you mean by invariant here?
2020-11-22 16:12:47 <dminuoso> I mean, I understand the meaning of it, just not the implication you are trying to make
2020-11-22 16:13:05 × berberman quits (~berberman@unaffiliated/berberman) (Quit: ZNC 1.7.5 - https://znc.in)
2020-11-22 16:13:20 <Feuermagier> ski, i refined my example a bit, but still dont have a solution: https://pastebin.com/4MdnjxhK I want "extract from example" to return the first element that "example" returns, which is unequal to 0. the [Int] it gets are the Integers to try.
2020-11-22 16:13:30 berberman joins (~berberman@unaffiliated/berberman)
2020-11-22 16:13:32 × Fractalis quits (~Fractalis@2601:987:280:8d40:eda9:f9e1:2072:cea7) (Ping timeout: 260 seconds)
2020-11-22 16:13:47 <Feuermagier> if all inputs fail, we just return 0
2020-11-22 16:14:48 <geekosaur> what happens if the first element succeeds? (which would be 0)
2020-11-22 16:14:51 <siwica> I am getting back into Haskell programming and just realized that Intero for Emacs does not seem to be maintened anymore. Which Emacs-mode/IDE are people using nowadays to write Haskell? Anything you guys can recommend?
2020-11-22 16:15:01 <geekosaur> this seems like a time to use Maybe
2020-11-22 16:15:15 gagbo joins (~gagbo@unaffiliated/gagbo)
2020-11-22 16:15:37 <Feuermagier> geekosaur, if the first element piped into "example" gives a result unequal to 0, we return the acquired result
2020-11-22 16:15:49 × phaul quits (~phaul@ruby/staff/phaul) (Ping timeout: 264 seconds)
2020-11-22 16:15:58 <merijn> siwica: Almost all IDE-like effort has been consolidated into haskell-language-server pretty much
2020-11-22 16:16:19 <ski> Feuermagier : oh, seems `asumMap' also happens to be the answer to your second question ;)
2020-11-22 16:16:21 <Feuermagier> siwica, IntelliJ with Haskell plugin performas adequate for me
2020-11-22 16:16:52 <Feuermagier> ski, enlighten me
2020-11-22 16:17:05 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2020-11-22 16:18:06 <siwica> merijn: Alright, thank you! Never did anything with language-server. Guess I'll have to take a look.
2020-11-22 16:18:15 <siwica> Anything people can recommend for Emacs in particular?
2020-11-22 16:18:38 × acidjnk_new quits (~acidjnk@p200300d0c719ff94358934eb0dfd70c0.dip0.t-ipconnect.de) (Ping timeout: 264 seconds)
2020-11-22 16:18:50 mananamenos joins (~mananamen@84.122.202.215.dyn.user.ono.com)
2020-11-22 16:19:04 <merijn> siwica: I'd recommend looking into the language server stuff anyway, because IMO LSP is pretty much the only sane way forward :p
2020-11-22 16:19:05 heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net)

All times are in UTC.