Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-15 12:18:32 <hpc> most useful specialized functions are secretly more useful and more abstract functions in disguise :D
2021-03-15 12:18:55 miklcct joins (quasselcor@2001:19f0:7001:5ad:5400:2ff:feb6:50d7)
2021-03-15 12:21:06 jamm_ joins (~jamm@unaffiliated/jamm)
2021-03-15 12:21:15 <curiousgay> merijn: that signature and that name mean: concatMap takes a function that transforms each element into the list, then it concatenates all those lists?
2021-03-15 12:21:18 × plutoniix quits (~q@184.82.207.25) (Quit: Leaving)
2021-03-15 12:23:42 <curiousgay> concatenated monads... so lists are monads
2021-03-15 12:23:42 <merijn> yes
2021-03-15 12:23:51 × xff0x quits (~xff0x@2001:1a81:52b7:0:73fe:50f7:6050:551e) (Ping timeout: 272 seconds)
2021-03-15 12:24:38 xff0x joins (~xff0x@2001:1a81:52b7:0:73fe:50f7:6050:551e)
2021-03-15 12:25:34 hidedagger joins (~nate@unaffiliated/hidedagger)
2021-03-15 12:25:43 <__minoru__shirae> if we talk in terms of kleisli arrows, then return is like id for kleisli arrows and bind is like fmap?
2021-03-15 12:25:52 <__minoru__shirae> not sure about bind
2021-03-15 12:26:45 <merijn> __minoru__shirae: You're thinking of the fish operator!
2021-03-15 12:26:50 <merijn> :t (>=>)
2021-03-15 12:26:51 <lambdabot> Monad m => (a -> m b) -> (b -> m c) -> a -> m c
2021-03-15 12:27:14 <merijn> With: f >=> g = \x -> f x >>= g
2021-03-15 12:28:18 <curiousgay> `(>>=) :: m a -> (a -> m b) -> m b` looks strange to me, because when I do something like `[1..5] >>= return . (+5)`, (+5) function doesn't generate lists
2021-03-15 12:28:18 <merijn> Well, >=> is more like (.) for Kleisli than fmap. But then again, fmap is (.) for "regular" functions
2021-03-15 12:28:49 <jumper149> curiousgay: Check the type of `return`
2021-03-15 12:29:20 <curiousgay> a -> m a
2021-03-15 12:29:29 heatsink joins (~heatsink@2600:1700:bef1:5e10:7c0e:3b57:dfb:2cb4)
2021-03-15 12:29:36 <jumper149> What is `m` in your example
2021-03-15 12:29:41 geowiesnot_bis joins (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr)
2021-03-15 12:29:58 <curiousgay> jumper149: "class Monad m where"
2021-03-15 12:30:09 × bergey` quits (~user@pool-74-108-99-127.nycmny.fios.verizon.net) (Ping timeout: 256 seconds)
2021-03-15 12:30:31 nhs joins (~nhs@cpe-70-113-67-118.austin.res.rr.com)
2021-03-15 12:30:37 <jumper149> curiousgay: Ok, write something like `return 5` into ghci
2021-03-15 12:30:57 forgottenone joins (~forgotten@176.42.16.157)
2021-03-15 12:31:35 <jumper149> curiousgay: ahhhhhh, sry no that is just confusing
2021-03-15 12:31:42 <enikar> into ghci, monad are "extracted"
2021-03-15 12:32:03 <enikar> so 'return 5', just prints 5
2021-03-15 12:32:30 <enikar> :t return 5
2021-03-15 12:32:33 <lambdabot> (Monad m, Num a) => m a
2021-03-15 12:32:34 <jumper149> What I wanted to say is: In the example `[1..5] >>= return . (+5)` the type of `return` gets unified to a concrete type
2021-03-15 12:33:03 <jumper149> The type of return is just:
2021-03-15 12:33:05 <jumper149> :t return
2021-03-15 12:33:07 <lambdabot> Monad m => a -> m a
2021-03-15 12:33:17 <geekosaur> enikar, not quite right, ghci will try to instantiate a monadic value as an IO action and if it succeeds, run the action
2021-03-15 12:33:35 × heatsink quits (~heatsink@2600:1700:bef1:5e10:7c0e:3b57:dfb:2cb4) (Ping timeout: 240 seconds)
2021-03-15 12:33:46 isson joins (1b7769ae@27.119.105.174)
2021-03-15 12:33:47 <enikar> geekosaur: ok.
2021-03-15 12:34:10 <jumper149> But in the context of lists it gets unfified to `return :: a -> [a]`
2021-03-15 12:34:29 drbean joins (~drbean@TC210-63-209-218.static.apol.com.tw)
2021-03-15 12:34:49 × ukari quits (~ukari@unaffiliated/ukari) (Remote host closed the connection)
2021-03-15 12:34:59 <enikar> :t return @[]
2021-03-15 12:35:00 <lambdabot> error:
2021-03-15 12:35:00 <lambdabot> Pattern syntax in expression context: return@[]
2021-03-15 12:35:00 <lambdabot> Did you mean to enable TypeApplications?
2021-03-15 12:35:06 × nhs quits (~nhs@cpe-70-113-67-118.austin.res.rr.com) (Ping timeout: 260 seconds)
2021-03-15 12:35:11 <geekosaur> % :t return @[]
2021-03-15 12:35:11 <yahb> geekosaur: a -> [a]
2021-03-15 12:35:21 <geekosaur> use yahb for TypeApplications
2021-03-15 12:35:23 ukari joins (~ukari@unaffiliated/ukari)
2021-03-15 12:35:33 <enikar> yes
2021-03-15 12:36:41 <__minoru__shirae> I mean, there is some relationship between fmap - bind and regular functions - kleisli arrows, but I don't know what that relationship is
2021-03-15 12:37:07 <isson> hi. i have a question. ( i am sorry i am not good to speak english.)
2021-03-15 12:37:07 <__minoru__shirae> hmm, what if we talk about Identity monad?
2021-03-15 12:37:40 <curiousgay> `return . f :: a -> m b` and `(>>=) -> m a -> (a -> m b) -> m b`, ah, so it's the return function being responsible for turning the result of (+5) into the list, but that means the return function itself is called many times?
2021-03-15 12:37:45 <isson> test = f (undefined :: a -> a)
2021-03-15 12:37:45 <isson> f :: (a -> b -> c) -> String
2021-03-15 12:37:46 <isson> f g = "test"
2021-03-15 12:38:13 <jumper149> __minoru__shirae: `Identity` is just a regular monad. What's the question?
2021-03-15 12:38:13 <enikar> curiousgay: exactly.
2021-03-15 12:38:24 <isson> [/home/isson/mynote/projs/haskell/Test/app/Main.hs:17:8-13] *Main Lib Paths_Test> :print g
2021-03-15 12:38:24 <isson> g = (_t1::(a -> b) -> String)
2021-03-15 12:38:50 pjb is now known as Guest83433
2021-03-15 12:38:51 Sheilong joins (uid293653@gateway/web/irccloud.com/x-dbopwiciasztapdp)
2021-03-15 12:38:55 <isson> i cannot understand, how id type is (a -> b) -> String ?
2021-03-15 12:39:19 × usr25 quits (~usr25@unaffiliated/usr25) (Quit: Leaving)
2021-03-15 12:39:29 <isson> how g's type is (a -> b) -> String ?
2021-03-15 12:39:36 <__minoru__shirae> jumper149, the question is how do you formulate (in simple terms) the relationship between fmap and regular functions and bind and kleisli arrows. Maybe they are the same?
2021-03-15 12:40:11 <merijn> __minoru__shirae: That depends on which relationship you're thinking off?
2021-03-15 12:40:31 arrowsvc_ joins (~arr@2.93.163.35)
2021-03-15 12:41:05 × Guest83433 quits (~t@2a01cb04063ec500f0530f573da1cece.ipv6.abo.wanadoo.fr) (Ping timeout: 246 seconds)
2021-03-15 12:41:24 pjb joins (~t@2a01cb04063ec50044b6cbec1ec8dc3b.ipv6.abo.wanadoo.fr)
2021-03-15 12:41:24 <merijn> __minoru__shirae: There are several I can think of, both Kleisli and functios are instances of: Profunctor, Kleisli, and Arrow
2021-03-15 12:41:33 <curiousgay> enikar: I remember tutorial mentioning that makes list comprehensions the syntactic sugar to these monad functions, it's just was mentioned too early
2021-03-15 12:42:00 <merijn> __minoru__shirae: Their functor/applicative/monad instances are also similar/the same
2021-03-15 12:42:25 <__minoru__shirae> "a monad is just a monoid in the category in which objects are functors" - I took this sentence from a book. I think it has somethig to do with the subject, and I don't yet fully understand it.
2021-03-15 12:43:31 <merijn> __minoru__shirae: You're maybe thinking off arrows/morphisms, because both functions and Kleisli are classical examples of CT morphisms
2021-03-15 12:44:22 <curiousgay> thanks everybody, now it's clear
2021-03-15 12:44:28 <curiousgay> :)
2021-03-15 12:44:28 <__minoru__shirae> and a monad is itself a functor
2021-03-15 12:44:42 <merijn> __minoru__shirae: Define "is"
2021-03-15 12:45:38 <__minoru__shirae> monad typeclass needs a functor constraint
2021-03-15 12:45:45 <merijn> __minoru__shirae: A functor consists of two morphisms: one between objects of two categories and one between morphisms in both categories
2021-03-15 12:46:40 <merijn> __minoru__shirae: ah, in that sense
2021-03-15 12:48:12 <merijn> __minoru__shirae: The things you need to define for a monad are a superset of the things you need to define a functor, so defining a monad (implicitly) defines a functor too (as shown by "fmap f x = x >>= return . f")
2021-03-15 12:50:12 <__minoru__shirae> fmap is like bind in which there is an implicit Identity monad
2021-03-15 12:51:23 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Quit: WeeChat 3.1)
2021-03-15 12:52:51 <geekosaur> isson, the g you show isn't in scope in ghci's top level, so I don't think you're getting a related response
2021-03-15 12:52:53 <__minoru__shirae> you have "Id a" and a function "a -> Id b" and using fmap you get "Id b", but you omit Ids
2021-03-15 12:53:23 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2021-03-15 12:53:23 × LKoen quits (~LKoen@194.250.88.92.rev.sfr.net) (Read error: Connection reset by peer)
2021-03-15 12:53:24 <__minoru__shirae> no, that sounds like a regular function application
2021-03-15 12:55:10 LKoen joins (~LKoen@194.250.88.92.rev.sfr.net)
2021-03-15 12:56:27 mirrorb2rd joins (~dwsjeid91@185.204.1.223)
2021-03-15 12:56:31 <__minoru__shirae> no, regular function application would be when you have a function "Id a -> Id b"
2021-03-15 12:57:40 urodna joins (~urodna@unaffiliated/urodna)
2021-03-15 12:57:58 × geowiesnot_bis quits (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr) (Ping timeout: 245 seconds)

All times are in UTC.