<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30 31
00:00 bydo joined
00:04 saussure joined
00:15 saussure joined
00:16 louispan joined
00:17 mjora7 joined
00:17 Rodya_ joined
00:26 takle joined
00:32 romank joined
00:39 takle joined
00:42 saussure joined
00:47 samtay joined
00:48 cschneid_ joined
00:53 takle joined
00:57 eacameron joined
01:00 juanpaucar joined
01:00 saussure joined
01:00 takle joined
01:07 vaibhavsagar joined
01:07 romank joined
01:09 Youmu joined
01:09 takle joined
01:19 takle joined
01:23 jship joined
01:30 romank joined
01:32 romank joined
01:36 romank joined
01:46 romank joined
01:49 peterbecich joined
01:49 romank joined
01:52 takle joined
01:57 seagreen joined
01:59 saussure joined
01:59 takle joined
02:06 romank joined
02:07 takle joined
02:11 romank joined
02:14 romank joined
02:16 romank joined
02:19 exferenceBot joined
02:23 hexagoxel joined
02:31 systemfault joined
02:38 takle joined
02:43 cschnei__ joined
02:44 saussure joined
02:45 romank joined
02:46 eacameron joined
02:46 wedens joined
02:51 takle joined
02:54 cschneid_ joined
02:58 takle joined
03:05 takle joined
03:06 haskelleksah joined
03:06 cschneid_ joined
03:10 gpampara joined
03:10 romank joined
03:11 cschneid_ joined
03:16 EvanR joined
03:16 EvanR left
03:18 dmj` joined
03:23 takle joined
03:29 DataComputist joined
03:34 takle joined
03:37 romank joined
03:38 juanpaucar joined
03:38 haskelleksah joined
03:45 takle joined
03:48 saussure joined
03:50 takle joined
03:53 saussure joined
03:56 <bitemyapp> colt44: `try` or `catch`?
03:56 <bitemyapp> I generally let exceptions kill the program after I've logged exactly what happened.
03:56 <bitemyapp> this being the context where "die" is an HTTP 500.
03:57 <bitemyapp> or a process can be restarted by systemd or summat.
04:00 romank joined
04:01 takle joined
04:09 romank joined
04:09 louispan joined
04:10 takle joined
04:14 romank joined
04:16 systemfault joined
04:19 romank joined
04:29 romank joined
04:34 romank joined
04:39 romank joined
04:41 eacameron joined
04:42 romank joined
04:42 takle joined
04:43 rstone joined
04:43 rstone joined
04:48 aarvar left
04:51 Lokathor joined
04:53 takle joined
04:53 saussure joined
04:59 systemfault joined
05:04 takle joined
05:05 romank joined
05:05 juanpaucar joined
05:15 romank joined
05:18 romank joined
05:19 meandi_2 joined
05:20 takle joined
05:22 haskelleksah joined
05:25 cschneid_ joined
05:36 takle joined
05:38 Kuros` joined
05:41 romank joined
05:44 RouxTheDay joined
05:49 takle joined
05:52 merijn joined
05:56 saussure joined
05:56 fotonzade joined
05:57 ThomasLocke joined
05:57 ThomasLocke joined
06:03 galderz joined
06:04 Deide joined
06:05 diegs_ joined
06:06 takle joined
06:08 pbrant joined
06:09 juanpaucar joined
06:12 takle joined
06:25 Robin_Jadoul joined
06:27 takle joined
06:27 exferenceBot joined
06:34 takle joined
06:36 romank joined
06:50 romank joined
06:51 takle joined
06:59 saussure joined
07:02 Pupnik joined
07:05 takle joined
07:06 bvad joined
07:08 louispan joined
07:10 alexelcu joined
07:16 romank joined
07:17 juanpaucar joined
07:29 romank joined
07:32 mattyw joined
07:37 zero_byte joined
07:42 nacon joined
07:42 nacon joined
07:42 zacts joined
07:44 thc202 joined
07:44 RouxTheDay joined
07:48 fbergmann joined
07:54 saussure joined
07:54 romank joined
07:55 louispan joined
07:56 alexelcu28 joined
07:57 alexelcu28 joined
07:58 alexelcu joined
07:58 nickolay_ joined
08:03 Gloomy joined
08:05 mjora7 joined
08:08 moei joined
08:10 mjora7 joined
08:11 romank joined
08:17 alexelcu joined
08:17 seanparsons joined
08:19 alexelcu joined
08:20 alexelcu joined
08:20 saussure joined
08:22 alexelcu joined
08:23 alexelcu joined
08:34 morsicus joined
08:35 juanpaucar joined
08:37 alexelcu joined
08:38 louispan joined
08:38 alexelcu joined
08:39 saussure joined
08:45 malaclyps joined
08:45 RouxTheDay joined
08:47 malaclyps joined
08:48 takle joined
08:52 alexelcu joined
08:53 mjora7 joined
08:53 alexelcu joined
08:57 saussure joined
08:59 DDR joined
08:59 abhiroop joined
08:59 <abhiroop> Can someone tell me what this `[t|T.Text|]` quasiquoted expression means in Haskell?
09:00 <abhiroop> I mean an equivalent haskell expresssion
09:00 louispan joined
09:08 romank joined
09:14 bluepixel joined
09:15 saussure joined
09:17 qu1j0t3 joined
09:20 prophile joined
09:22 Kuros` joined
09:27 louispan joined
09:33 saussure joined
09:33 merijn joined
09:44 galderz joined
09:51 conal joined
09:51 alexelcu joined
09:51 saussure joined
09:56 romank joined
09:58 juanpaucar joined
10:03 alexelcu joined
10:11 saussure joined
10:22 haskelleksah_ joined
10:23 cschneid_ joined
10:25 im0nde joined
10:26 mattyw joined
10:30 mattyw joined
10:30 saussure joined
10:39 Levex joined
10:39 alexelcu joined
10:46 RouxTheDay joined
10:51 netheranthem joined
10:57 saussure joined
10:58 jarshwah joined
11:07 alexelcu joined
11:07 juanpaucar joined
11:07 alexelcu left
11:08 alexelcu joined
11:10 acarrico joined
11:11 jarshwah_ joined
11:16 saussure joined
11:18 zero_byte joined
11:21 Xion_ joined
11:25 malaclyps joined
11:26 saussure joined
11:35 c4r50nz joined
11:36 saussure joined
11:38 Gloomy joined
11:43 juanpaucar joined
11:46 zero_byte joined
11:47 RouxTheDay joined
11:47 yellowj joined
11:49 juanpaucar joined
11:54 saussure joined
11:55 mattyw_ joined
12:05 saussure joined
12:07 juanpaucar joined
12:16 mengu joined
12:30 chlong joined
12:42 saussure joined
12:43 juanpaucar joined
12:47 eacameron joined
12:53 levex_ joined
12:56 jathan joined
13:00 saussure joined
13:10 eacameron joined
13:12 saussure joined
13:12 Bhootrk_ joined
13:15 tuusj joined
13:21 saussure joined
13:23 iAmerikan joined
13:25 mr_sm1th joined
13:25 <colt44> bitemyapp: I ended up usin catchError, as dmj` pointed out. In this case, I don't want to let the exception kill the program and return a big, ugly, sql error to the client, because of a unique constraint violation.
13:26 haskelleksah joined
13:27 conal joined
13:28 bluepixel joined
13:32 Cale joined
13:44 carlomagno joined
13:48 RouxTheDay joined
13:49 saussure joined
13:52 juanpaucar joined
14:02 juanpaucar joined
14:21 jathan joined
14:25 kritzcreek joined
14:26 MichielDC joined
14:30 yellowj joined
14:43 juanpaucar joined
14:44 aarvar joined
14:46 bluepixel joined
14:47 bluepixel joined
14:49 bluepixel joined
14:49 RouxTheDay joined
14:58 mjora7 joined
15:01 cschneid_ joined
15:04 bluepixel joined
15:06 twopoint718 joined
15:09 bluepixel joined
15:09 mengu joined
15:10 Gloomy joined
15:13 colt44 joined
15:13 pranitbauva1997 joined
15:22 uglyfigurine joined
15:23 juanpaucar joined
15:24 conal joined
15:25 Gurkenglas joined
15:38 jathan joined
15:39 chlong joined
15:46 rotsix joined
15:47 saussure joined
15:49 RouxTheDay joined
15:54 Durbley joined
15:56 <zacts> hi #haskell beginners
15:57 <zacts> ok, I'm going to actually make myself get past ch 1 of the haskellbook.com book
15:57 <zacts> after that I should just get into really easily
15:58 <zacts> the 1st ch is just tough for me, as it's more theoretical. I like practical explanations, but I do realize why this ch is important
15:58 yellowj joined
16:01 saussure joined
16:03 <Xion_> Speaking of practical, I saw an article once that nicely described Python as a "platform": coding & project conventions, how to use a package manager, list of common packages to use (logging, HTTP, web, data format parsing, command line flags, etc.), and other similar things. Is there something equivalent for Haskell somewhere?
16:03 <Xion_> I know some of those questions can be answered with "just use Stack".
16:03 <geekosaur> https://haskell.com/platform
16:03 <geekosaur> er
16:03 <geekosaur> https://haskell.org/platform
16:04 <geekosaur> widely hated because anyone who drank the stack koolaid is more or less forced to work in ways that are incompatible with the entire concept
16:04 <Xion_> Well yes, this is where to *get* the Haskell platform :)
16:04 <Xion_> Oh okay, it has some common libraries.
16:07 <geekosaur> fewer than it used to
16:10 juanpaucar joined
16:16 mr_sm1th joined
16:27 mclaren joined
16:54 pilne joined
16:58 Big_G joined
16:59 twopoint718 joined
17:00 <mclaren> hello
17:03 <mclaren> alright then
17:03 peterbecich joined
17:14 <Xion_> Hey.
17:19 juanpaucar joined
17:21 conal joined
17:23 developernotes joined
17:26 <mclaren> hey xion
17:26 <mclaren> hey Xion_ *
17:28 erisco joined
17:34 juanpaucar joined
17:35 kaychaks_ joined
17:35 juanpaucar joined
17:42 uglyfigurine joined
17:47 eacameron joined
17:48 iAmerikan joined
17:53 Cale joined
17:55 chlong joined
17:58 sbrg joined
17:58 sbrg joined
18:01 pranitbauva1997 joined
18:03 douglascorrea joined
18:04 sbrg joined
18:04 sbrg joined
18:10 mac10688 joined
18:23 bvad joined
18:25 juanpaucar joined
18:27 yellowj joined
18:37 acarrico joined
18:55 Xion__ joined
18:55 Tomatosoup- joined
18:55 <Tomatosoup-> hi
18:56 Cale joined
18:56 Zaghie joined
18:57 <Tomatosoup-> what does it mean when you pass a function to Num? e.g f ::Num (a -> b) => [a] -> [b]
18:59 ebw joined
19:02 shainer joined
19:03 <Tomatosoup-> btw if you wonder, this is the function that has this type: f x = map (-1) x
19:03 shainer left
19:03 <ski> it will attempt to interpret the numeral as a function. but that assumes there's a `Num' instance for functions in scope
19:04 <ski> if you haven't made (or imported) one, there is no such instance in scope. that's why the unresolved `Num (a -> b)' constraint appeared in your type
19:05 <geekosaur> Tomatosoup-, you've hit an edge case of Haskell syntax
19:06 <geekosaur> negative numbers are a hack. you need the parentheses to make the - be handled as part of a negative number. but that means you don't get to use sections on (-)
19:06 <geekosaur> so, we have another hack
19:06 <geekosaur> :t (subtract 1)
19:06 <lambdabot> Num a => a -> a
19:06 <Tomatosoup-> so it same way, Num [a] interpret numbers as lists, but i have to declare an Num instance for any lists?
19:06 <ski> if you want to, you could make an instance like `instance Num a => Num (rho -> a) where (f + g) r = f r + g r; ...; fromInteger n r = n' -- this is the "pointwise" instance, which is sometimes useful
19:06 juanpaucar joined
19:07 <Tomatosoup-> geekosaur, i'm studying some category theory and approched this without explaination
19:07 <ski> using it, one can write polynomials like `id^2 - 3*id + 5', which will evaluate to the same function as `\r -> r^2 - 3*r + 5'
19:07 <geekosaur> nevertheless, your example `map (-1)` looks like it runs squarely into this syntax wart
19:09 <ski> (a numeral like `1' will be interpreted as `fromInteger 1', where this `1' is now an `Integer'. in the above case, it means that `1' will be interpreted as `\r -> 1', and `- 1' as `negate (\r -> 1)', which is equivalent to `\r -> negate 1')
19:11 <ski> (this is how numerals can be polymorphic. the context determines which type it will have. in your `map' example, the context determined its type to be a function type, because that's what the first argument to `map' must be)
19:14 <Tomatosoup-> i think i get it now, thanks
19:14 mengu joined
19:15 govg joined
19:19 Cale joined
19:21 mengu joined
19:23 <lpaste> ebw pasted “Reduce duplication, but how?” at http://lpaste.net/355759
19:23 <ebw> hlint yells at me to reduce duplication between the arbitrary functions for Three and Three', but how?
19:24 <ebw> In http://lpaste.net/355759 that is
19:25 <monochrom> what line numbers did hlint say?
19:26 <ebw> 9 and 22, but I thing I see it now. Just make a function, that takes the data constructors Three and Three' as argument?
19:27 mengu joined
19:27 <monochrom> I don't know. I would not worry about it.
19:31 merijn joined
19:34 juanpaucar joined
19:34 <lpaste> ebw annotated “Reduce duplication, but how?” with “Reduce duplication, but how? (annotation)” at http://lpaste.net/355759#a355760
19:35 <merijn> You could also write "f <$> arbitrary <*> arbitrary <*> arbitrary" and avoid coming up with names :)
19:39 ebw joined
19:39 <ebw> I annotated the above link. Got It.
19:45 seanparsons joined
19:48 l3dx joined
19:51 mengu joined
19:51 nullcone joined
19:54 mengu joined
19:56 <Tomatosoup-> ski, geekosaur: one more question. What if i do smth like this f :: (Num (a -> b), Num (c -> (a -> b)) => ... (two Num instances installed in different functions? how does it know which one to choose from?)
19:57 DataComputist joined
19:57 <geekosaur> you do understand that all Haskell functions take one argument and produce one value?
19:57 juanpaucar joined
19:57 <Tomatosoup-> ye, that's how currying works
19:57 <geekosaur> also "two Num instances installed in different functions" sounds wrong/confused
19:58 <geekosaur> you'd get one Num instance for all functions
19:58 <geekosaur> more complex ones would reduce to multiple uses of that instance, if they can be resolved at all
19:58 uglyfigurine joined
19:58 haskelleksah joined
19:59 mengu joined
19:59 <Tomatosoup-> so what does it mean that if define two Num versions ?
19:59 <Tomatosoup-> s/if/if I/
20:00 <Tomatosoup-> like in the example above
20:00 <Tomatosoup-> patter matching for the most appropriate one?
20:01 <ski> i haven't seen you declare any `Num' instances
20:02 <ski> the type checker is merely noting that it'll need to resolve one `Num' instance for the type `a -> b', and one for the type `c -> a -> b', in order to be able to use `f'
20:03 <Tomatosoup-> ic, so why the hell would i want to define f :: (Num (a -> b), Num (c -> (a -> b)), and how it is resolved in f ?
20:03 <ski> unless you mean to be using any such instances, this is an indication that you're doing something wrong .. like missing an operator symbol, or something similar
20:03 <monochrom> Yes, what have you done indeed?
20:04 <Tomatosoup-> i'm not defining anything useful, i know haskell basics, i'm getting into more deeper type behaviour
20:04 <ski> i don't know why you'd want to define an `f' with type signature `f :: (Num (a -> b),Num (c -> (a -> b)) => ..a..b..c..' .. where did you get that signature from ?
20:04 <geekosaur> you might want to start with something simpler
20:05 <Tomatosoup-> approached this while trying to deduce this type: f'x = map - (1 x)
20:05 <ski> is this a type signature that is inferred from some code you're written ?
20:05 <ski> ok -- that looks very confused
20:05 <ski> what are you trying to accomplish with this piece of code ?
20:05 <Tomatosoup-> i've simplified the type, because type of f' x = map - (1 x) is even more complex
20:06 <monochrom> 1*x, not 1 x
20:06 <geekosaur> thi started out with [22 19:03:10] <Tomatosoup-> btw if you wonder, this is the function that has this type: f x = map (-1) x
20:06 <Tomatosoup-> monochrom, nope, (1 x)
20:06 <geekosaur> I ... do not want to know how it mutated
20:06 <ski> `1 x' means : apply the *function* `1' to the argument `x' -- this is probably not what you want to do
20:06 <monochrom> 1 x is the cause of the strange Num requirement.
20:07 <Tomatosoup-> monochrom, yep, it is.
20:07 <ski> the cause of one of them
20:07 <Tomatosoup-> i want that :P
20:07 <monochrom> Then again I don't know what the hell is "map - (1 x)" supposed to mean.
20:07 <ski> trying to subtract something from `map' is the cause of the other one
20:08 <monochrom> "f x = map negate x" would be a very sensible piece of code.
20:09 <Tomatosoup-> here is the background: i'm studying category theory and functional programming in haskell, i've written some interpreters, got into monads transformers etc. Now i'm playing with types, trying to understand more complex stuff
20:09 <Tomatosoup-> so yes, i want to understand the type of exactly f' x = map - (1 x)
20:10 <monochrom> I recommend studying type inference algorithms then.
20:10 <monochrom> Look for "typing haskell in haskell".
20:11 systemfault joined
20:12 <ski> presumably the type of `x' here is `c', and the type of `1' (in `1 x') is `c -> (a -> b)', which causes the `Num (c -> (a -> b))' constraint. so `1 x' has type `a -> b', which would also be the type of `map' (hm, does this make sense ?), since `map' and `1 x' are the two operands passed to the operator `-'
20:12 chrissl joined
20:12 <ski> (if this is the regular `map' from `Prelude', what happened to the list type parts in its type ?)
20:13 saussure joined
20:13 <Tomatosoup-> ski, i have simplified the type so that it is easier to reason about, full type for f' is :: (Num ((a -> b) -> [a] -> [b]), Num (t -> (a -> b) -> [a] -> [b])) => t -> (a -> b) -> [a] -> [b]
20:13 <ski> (oh, and that subtraction would then cause the `Num (a -> b)' constraint)
20:14 <ski> Tomatosoup- : ok, that makes more sense
20:14 <ski> all is clear
20:14 <Tomatosoup-> Num ((a -> b) -> [a] -> [b]) is understandable, becase types of map needs to match, but what about next Num?
20:14 <ski> that constraint is because `map' is passed to `-', yes
20:15 <ski> but `1 x' must then also have type `(a -> b) -> [a] -> [b]'
20:15 saussure joined
20:15 <Tomatosoup-> so we define another Num (t -> (a -> b) -> [a] -> [b])) so that the types for (1 x) match?
20:16 <Tomatosoup-> (define another Num might be not-so-good words here, but you get the idea)
20:16 <ski> so, if `x' has some type, call it `t', then `1' here must have type `t -> (a -> b) -> [a] -> [b]' .. which requires the `Num (t -> (a -> b) -> [a] -> [b])' constraint in order to convert the `Integer' `1' to this type, via the implicit `fromInteger' conversion
20:16 <ski> (remember `1' means `fromInteger 1')
20:17 <ski> and the whole subtraction `map - 1 x' then has the same type as the operands, i.e. `(a -> b) -> [a] -> [b]'
20:17 <Tomatosoup-> ok, i get it
20:17 <ski> Tomatosoup- : there is no "we define another Num ..." here. there is no definition of anything, apart from of f'
20:18 <ski> we *require* another `Num' constraint would be clearer
20:18 brezel joined
20:18 <Tomatosoup-> monochrom, thanks for that, will get into it
20:18 <* ski> hopes this makes it clear
20:19 <Tomatosoup-> yes, it is :)
20:19 <Tomatosoup-> thanks for your time ski, much appreciated
20:19 <ski> you might perhaps be interested in reading another paper about type inference
20:19 <ski> let me dig up the reference
20:20 <ski> "Polymorphic Type Inference" by Michael I. Schwartzbach in 1995-03 at <http://web.cecs.pdx.edu/~antoy/Courses/TPFLP/lectures/TYPE/typeinf.p(s|df)>
20:20 <ski> Tomatosoup- : try that ^ one ?
20:20 <Tomatosoup-> ok, will check it
20:22 <ski> it doesn't contain info about how to type check and infer type class stuff. only basic stuff. could still be useful, if you're not so familiar with the territory
20:22 <ski> i know it helped me, when i started reading about type systems
20:25 Durbley joined
20:30 eacamero_ joined
20:30 <DataComputist> myFunc :: type1 -> type2 -> type3 -> type4
20:31 <DataComputist> Does this mean it constrains the function myFunc to accept three arguments of type type1, type2, type3 and return a value of type4?
20:31 chlong joined
20:31 <DataComputist> I've not read the basic intro on this part yet but want to know quickly what this means.
20:33 <kadoban> DataComputist: Yes, though lower-case types are variables, so I'd not call it a constraint at all.
20:33 douglascorrea joined
20:33 <geekosaur> I'm reading those as metavariables
20:33 <kadoban> Oh
20:33 <kadoban> Maybe
20:33 <geekosaur> for a beginning understanding, "yes". when you get to partial application, you'll discover the real story including why we write it that way
20:34 Durbley joined
20:35 <geekosaur> Haskell's function syntax is designed to both encourage and get the most mileage out of partial application. But it does take some getting used to
20:36 <geekosaur> especially when you haven't encountered partial application yet, so you're wondering why in the world we would do silly things like that :)
20:41 iAmerikan joined
20:43 sync__ joined
20:47 mjora7 joined
20:49 uglyfigurine joined
20:51 uglyfigurine joined
20:51 uglyfigurine joined
20:59 lewis joined
21:07 Big_G joined
21:09 conal joined
21:29 greeny joined
21:36 <DataComputist> In GHCi, how to print the type of a symbol?
21:37 mjora7 joined
21:38 <ski> you can use `:type ...' to ask for the type of an expression (`:t ...' for short)
21:39 <ski> if you want the type of an operator, like `+', you'll have to "section" it, like `:t (+)'
21:40 <ski> `3 + 4' means the same as `(+) 3 4'. putting brackets around an infix operator converts it to a normal (prefix) function
21:52 hiratara joined
22:00 iAmerikan joined
22:03 saussure joined
22:05 <DataComputist> Which link in https://www.haskell.org/documentation is the primary go-to for looking up the basic info of a Haskell keyword such as `pure`?
22:06 zero_byte joined
22:06 <DataComputist> And, if someone could please just tell me quickly what does 'pure a' at the end of a function definition means?
22:07 Gloomy joined
22:10 <glguy> DataComputist: In the context of IO, (pure x) is the action that does with the result (x)
22:10 <glguy> The result of the action being defined by do-notation is the result of the last action
22:10 <glguy> DataComputist: In the context of IO, (pure x) is the action that does nothing and finishes with the result (x) (*edit)
22:13 im0nde joined
22:17 <ski> also, it's not a keyword, it's an ordinary (overloaded) function :)
22:18 mengu joined
22:18 saussure joined
22:31 fotonzade joined
22:31 hiratara joined
22:32 Nik05 joined
22:35 <DataComputist> So, why 'pure x' is necessary? Why can't I just end the function definition with a 'x'?
22:36 <DataComputist> Example I'm considering:
22:36 <DataComputist> https://www.irccloud.com/pastebin/EHCLNsdU/pure_ex
22:36 saussure joined
22:36 <DataComputist> So what if I just use 'n' instead of 'pure n'.
22:37 <glguy> n isn't an action that does nothing and then returns n
22:37 <glguy> so you'd just get a type error
22:38 <DataComputist> So 'pure n' is to comply with the type spec 'IO Int'?
22:38 Levex joined
22:38 <glguy> The expression on each line of do-notation needs to have a type of the form (m a) where all the m's match
22:39 <glguy> It's like writing 1 when you meant the singleton list of one: [1]
22:39 <glguy> It's not a list, so you can't replace the one with the other
22:42 <DataComputist> I can't see why for example the line 'print "Hello world!"' comforms to what you said.
22:42 <DataComputist> conforms
22:43 <glguy> You'd have to elaborate. I don't know what you're trying to show with what you wrote
22:43 DataComputist joined
22:43 <glguy> GHCi executed the action (f 1), which printed "Hello world!" and 1
22:43 <glguy> and then GHCi separately printed the result of your action because it can be printed
22:43 <glguy> That's just a quirk of GHCi
22:44 mjora7 joined
22:45 <DataComputist> So what I'm still a little puzzled with is why
22:45 <DataComputist> 'print "Hello world!"'
22:45 <DataComputist> and
22:45 <DataComputist> pure n
22:45 <DataComputist> both have the type of form (m a)
22:45 <DataComputist> ?
22:45 <glguy> print "Hello World" :: IO ()
22:45 <glguy> pure n :: IO Int
22:45 <glguy> so the m is IO
22:45 <glguy> and the a is allowed to vary
22:46 saussure joined
22:46 <DataComputist> so pure is a special thingy of the type IO?
22:46 <DataComputist> Which link in https://www.haskell.org/documentation is the primary go-to for looking up the basic info of a Haskell keyword such as this `pure`?
22:46 <glguy> pure :: Applicative m => a -> m a
22:47 <glguy> ?hackage base
22:47 <lambdabot> http://hackage.haskell.org/package/base
22:47 <glguy> pure is in the base package
22:47 <glguy> There's an [index] link on the contents page for looking things up by name rather than by module
22:48 <ski> `pure' here converts the `n' of type `Int' into an action of type `IO Int', an action that actually does no I/O, merely yield `n' as result
22:48 <ski> `pure' is also overloaded, so it'll work for some other things than `IO' as well
22:48 <ski> (that's the `Applicative' bit)
22:49 <ski> @where hoogle
22:49 <lambdabot> http://haskell.org/hoogle http://fpcomplete.com/hoogle – See also Hayoo, which searches more packages: http://hayoo.fh-wedel.de/
22:49 <ski> could be useful, when looking for an operation
22:49 <ski> @hoogle pure
22:49 <lambdabot> Prelude pure :: Applicative f => a -> f a
22:49 <lambdabot> Control.Applicative pure :: Applicative f => a -> f a
22:49 <lambdabot> Diagrams.Prelude pure :: a -> f a
22:50 <ski> (and again, it's not a keyword)
22:53 <ski> a `do'-expression (when itself being executed) will execute all the commands inside it, in order. the result value yielded by the last command will be the overall result value yielded when executing the whole `do'-expression (being an action)
22:53 eacameron joined
22:54 <ski> (it's also possible to name the result value yielded by executing an earlier command in a `do'-expression, by prefixing it with the desired variable name, and the `<-' symbol (a keyword, just like `do'))
22:56 <ski> (however, in the case of `print ...', there is no interesting result value yielded when executing it .. so there'sn't much point in naming it there)
22:56 <ski> DataComputist : does that help ?
22:57 <DataComputist> Yep, a few lines in the above still need more digesting ...
22:57 <DataComputist> Very helpful. Thank you all.
22:58 <ski> btw, you should note that merely *evaluating* an action does not cause execution of it. that's a separate matter
22:59 <DataComputist> For an arbitrary snippet like 'print "Hello World"', how to find its type in GHCi?
22:59 <ski> use `:type print "Hello World"'
22:59 <ski> you can use `:t' as an abbreviation of `:type'
23:01 <ski> the `()' in the type of that is the "unit" type. it has only one (defined) value, also written `()'
23:02 <ski> the unit type is often used when some result type is needed, but one has no interesting thing to return
23:02 <DataComputist> Not entirely clear what the 'Applicative m => ' part in 'pure :: Applicative m => a -> m a' actually means.
23:03 <ski> in this case, all the interesting parts of that action is in the input/output (only the latter here) effects of executing the action
23:03 eacameron joined
23:03 <ski> that specifies that `pure' is overloaded .. possibly leave that for now, until you've familiarized yourself a bit with basic type classes like `Eq' and `Num' ?
23:04 saussure joined
23:04 <DataComputist> Right, that's what I'm thinking too. My current understanding is that `pure` will "lift" a value 'a' to 'm a' so it conforms to the type spec of the outer function.
23:04 <ski> (and before that, you should also have a basic idea of what polymorphism is)
23:05 <ski> DataComputist : *nod*, that's a good enough understanding for now, i think
23:05 <ski> (in your case, `m' is `IO')
23:06 <ski> Haskell is pretty hard on distinguishing a value (say an integer), from an action, which when executed (apart from doing some effects, say input/output ones), will eventually result in a value (like that integer)
23:06 <ski> this is similar to distinguisihing a cake from a recipe for making a cake
23:07 <ski> following (executing) the recipe takes resources, interaction, and might perhaps even fail sometimes
23:08 <ski> the result may depend on your particular circumstances, what ingredients, or quality thereof, you have handy, &c.
23:09 <ski> `pure' is a way to pretend a value is an action. executing that action will then do nothing at all, except give back the value you started with
23:09 <ski> the point of this is commonly to build a larger action out of smaller ones. e.g. using `do'-notation
23:11 twopoint718 joined
23:11 <ski> (btw, just to make it clear. actions are values too. they are a particular kind of value. just like integers are one kind of value, lists are another, and functions yet another kind of value)
23:12 <ski> (there are other kinds of actions than `IO' actions .. but that's probably the kind of actions you'll run into the most, when starting out)
23:13 <* ski> glances at DataComputist
23:13 saussure joined
23:15 eacameron joined
23:19 malaclyps joined
23:19 eacamero_ joined
23:27 danny_ joined
23:28 eacameron joined
23:31 saussure joined
23:38 jship joined
23:41 saussure joined
23:43 louispan joined
23:59 saussure joined
23:59 eacameron joined