<    April 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
00:00 Rodya_ joined
00:02 eacameron joined
00:02 geekosaur joined
00:06 contiver joined
00:08 <geekosaur> traceShow "not working" usually means the value didn't get evalated; look further up
00:08 eacameron joined
00:08 <MarcelineVQ> mac10688: codingame?
00:11 <mac10688> yeah!
00:12 <mac10688> geekosaur, I thought about the not evaluating thing. I thought I had it covered, but it seems that it errored out before it got to my traceShow
00:13 <mac10688> this problem seems a lot harder to me without a double for loop at my disposal
00:15 eacameron joined
00:20 eacameron joined
00:21 <ski> i'm not quite sure why it prints that initial prefix, but ..
00:21 <ski> mac10688 : it seems at least one of line `11' and line `28' must be wrong
00:22 <ski> line `66' should probably use `*' somewhere
00:22 takle joined
00:23 dni- joined
00:24 <ski> (line `72' could be using `unlines' (or `intercalate') and `map' (or a list comprehension) .. this would be more efficient)
00:24 <mac10688> well it looks you like can't read "E" :: String
00:24 <mac10688> ok
00:24 <ski> (line `60' could be using `fromMaybe', and a section of `M.lookup')
00:25 <ski> exactly
00:26 <ski> (or line `60' could be using `ord' and `-' (and possibly `inRange') instead of `dictionary')
00:26 <geekosaur> > read "\"E\"" :: String
00:26 <lambdabot> "E"
00:26 <mac10688> I like that fromMaybe function
00:26 <ski> looks like line `28' or `32' is missing a `map toUpper' ?
00:26 <geekosaur> remember that Read and Show are expected to work with something resembling Haskell source
00:27 eacameron joined
00:27 <ski> line `50' (or `35', if you prefer) probably wants to use `putStr' or `putStrLn' rather than `print'
00:27 <ski> mac10688 : line `66' is using a "double for loop", as you call it, btw
00:28 <mac10688> yeah when I googled how to use a double for loop in haskell, everyone said to use list comprehensions, which kind of lead me to that function
00:30 <ski> i'd try profiling it with `asciiArt' being an `Array (Int,Int) Char' (or `[Array Int Char]', as you please) rather than a `[String]' .. `!!' on line `69' hurts the eye
00:30 splanch joined
00:31 <ski> > listArray (0,9) "abcdefghij" ! 5
00:31 <lambdabot> 'f'
00:32 <mac10688> oh geekosaur I just saw your example too. Thanks
00:32 <mac10688> it's taking me a while to go back and forth and fix up my code lol
00:33 <mac10688> I could have sworn I had toUpper in there somewhere
00:33 eacameron joined
00:33 conal joined
00:36 <ski> commented out
00:37 <ski> btw, `readLn' is probably better than `read <$> getLine'
00:37 <mac10688> oh nice
00:37 <mac10688> oh ok, I'll fix that before i officially submit this
00:37 <ski> the difference is that `readLn' will error out when executing, if the reading doesn't work
00:38 <ski> with that `read <$> getLine', you'll only get the error when you later actually try to access the result
00:38 ali_bush joined
00:38 ali_bush joined
00:38 <ski> fwiw, `{- ... -}' comments can span multiple lines
00:38 takle joined
00:38 <ski> also, instead of doing
00:38 <ski> "foo"
00:38 <ski> ++ "bar"
00:39 <ski> you can do
00:39 <ski> "foo\
00:39 <ski> \bar"
00:39 <mac10688> I tried doing quasi quotes but I didn't know
00:39 <mac10688> oh that is nicer
00:40 <ski> instead of `!!' on lines `26',`27',`28' (together with line `30') i'd use `let ls:hs:ts:asciiArt = lines content'
00:40 <ski> if you have several `let's in a row in a `do'-expression, you can omit all but the first `let' (as long as you align the start of the individual definitions)
00:42 conal joined
00:43 <ski> personally, i'd consider placing the `?' first, so that i didn't have to hardcode `26' at line `57' like that
00:43 <ski> (one could also compute the length of ['A' .. 'Z'] , but it feels a bit clumsy)
00:43 <mac10688> I can't change that
00:43 <mac10688> that's how the problem poses it
00:44 <* ski> was suspecting so
00:50 peterbecich joined
00:52 <Durbley> can someone tell me why this doesn't work
00:52 <Durbley> data Blah a b = (->) a b
00:52 <Durbley> (\x->x+1) :: Blah Integer Integer
00:53 <ski> missing data constructor in the data type definition
00:53 <ski> well, or you wanted to use `type', not `data'
00:53 <ski> (more likely, considering your latter line)
00:54 <Durbley> ah
00:54 <Durbley> difference between data, type, and newtype?
00:55 <ski> `type' gives a new name to an existing type (possibly parameterized)
00:55 <ski> `data' and `newtype' constructs new data types
00:55 <ski> `newtype' is like a restricted version of `data', that insists on a single data constructor having a single component/argument
00:56 <ski> `newtype' is like `type', except you can't accidentally confuse the new type from the old (representation) type. you have to explicitly convert by using the data constructor
00:56 dkeathley joined
00:57 sujeet joined
00:57 <ski> if you use `type Age = Int' and `type Count = Int', then you can confuse an `Age' for a `Count', since both are just shorthand for `Int'
00:57 <ski> if you use `newtype Age = MkAge Int' and `newtype Count = MkCount Int', then you can't confuse an `Age' for a `Count' (or any of those with an `Int')
00:57 eacameron joined
00:58 takle joined
00:58 <Durbley> by single data constructor you mean no |
00:58 <ski> in implementations, a `newtype' is intended to not add any extra run-time representation, over the representation type. this also means that a `newtype' data constructor is always strict, and that matching on it forces nothing
00:58 <ski> right
00:59 <Durbley> it makes sense to put functions in data constructors e.g. Maybe (\x->x+1)
00:59 <Durbley> right
01:00 <ski> if you know you won't need multiple alternatives (nor multiple components), then you may choose `newtype'. if you might need it, then choose `data'
01:00 <ski> `type' is handy less often that newbies often seem to think
01:01 <ski> Durbley : is that a question ?
01:01 <Durbley> yes
01:02 <geekosaur> Durbley, `\x -> x + 1` is a value with a function type; it cant be usedwith Maybe (a type constructor) but could be used with Just (a data constructor)
01:02 <geekosaur> on the other hand, its type is Num a => Maybe (a -> a)
01:03 <Durbley> i c
01:03 <Durbley> how would you define a dummy type that just holds a function
01:03 <Durbley> like Blah (\x->x+1)
01:04 <monochrom> There is a simply way. But I recommend just using (\x -> x+1) alone.
01:04 <geekosaur> Durbley, what are you trying to do exactly?
01:04 <Durbley> not asking for a practical reason just wondering how it's done
01:04 <geekosaur> I'm trying to figure out wexactly what you are asking for...
01:04 <monochrom> "Functions are first-class." You don't have to "protect" a function by a wrapper. Just pass it as a parameter.
01:04 <geekosaur> Just (\x -> x + 1) :: Num a => Maybe (a -> a)
01:05 <Durbley> ye I'm not using this for anything
01:05 <geekosaur> :t Just (\x -> x + 1)
01:05 <lambdabot> Num a => Maybe (a -> a)
01:05 <monochrom> OK. newtype F = FOf (Integer -> Integer). Now you can have FOf (\x -> x + 1).
01:06 <monochrom> In general you will want to learn user-defined types (algebraic data types) properly. Then you can do anything you want.
01:11 <Durbley> thanks I think I get it. I forget the difference between type, data, and newtype every week it seems
01:16 stef_204 joined
01:16 <mac10688> geekosaur, earlier you showed me that I needed to escape quotes to read it as a string. The issue is that my input doesn't escape the letter E with quotes
01:16 <geekosaur> then why do you need read?
01:16 <mac10688> do you know how I can read the line and convert it to a string?
01:17 <mac10688> oh
01:17 <mac10688> getLine
01:17 <mac10688> duh!
01:17 <mac10688> thanks
01:20 irclogger_com joined
01:20 Topic for
01:20 <mac10688> thanks for the help guys, I have code that works I think. Going to run tests and submit it
01:21 sujeet joined
01:23 <ski> next time, you could "Annotate" (or maybe "Edit") the original paste with updates. as an annotation, it'll end up on the same page as the original, for easier comparision
01:23 <ski> line `39' could be just `asciiArt <- replicateM h getLine'
01:24 <mac10688> I'll do that next time
01:24 <mac10688> time for dinner. I worked up a frenzy!
01:24 <ski> `(position * length + length - 1)' can be written as `(position + 1) * length - 1'
01:25 <* ski> would personally refrain from using `$'
01:25 <ski> (except maybe for line `39', i.e.)
01:27 eacameron joined
01:30 vaibhavsagar joined
01:38 eacameron joined
01:39 alasi joined
01:43 eacameron joined
01:46 eacamero_ joined
01:52 systemfault joined
01:54 malaclyps joined
01:59 mreed0xfffffffff joined
02:00 malaclyps joined
02:08 takle joined
02:11 mac10688 joined
02:11 dkeathley joined
02:12 vaibhavsagar joined
02:12 dni- joined
02:17 takle joined
02:17 exferenceBot joined
02:22 hexagoxel joined
02:22 MotherFlojo joined
02:27 takle joined
02:29 aarvar joined
02:33 takle joined
02:34 splanch joined
02:35 splanch left
02:40 eacameron joined
02:40 jgertm joined
02:45 MotherFlojo joined
02:46 patbecich joined
02:49 takle joined
02:56 mac10688 joined
03:00 fred-fri joined
03:00 andyhoang joined
03:04 mreed__ joined
03:05 takle joined
03:11 mreed__ joined
03:13 mreed___ joined
03:14 mreed__ joined
03:14 sigmundv joined
03:15 mreed__ left
03:18 mreed__ joined
03:23 andyhoang joined
03:32 madgoat joined
03:35 andrewhn joined
03:35 madgoat left
03:37 <fred-fri> turns out all i had to do was insert a single fromIntegral inside my roundfive function: https://pastebin.com/9yZkEV7G
03:38 <benzrf> heh
03:38 mac10688 joined
03:39 <fred-fri> and yes, the function is poorly named as it doesnt always round to five but it adheres to the logic for https://www.hackerrank.com/challenges/grading
03:53 dkeathley joined
03:58 malaclyps joined
04:01 dni- joined
04:26 monty joined
04:26 kori joined
04:28 darthdeus joined
04:32 monochrom joined
04:32 wei2912 joined
04:33 alpounet joined
04:36 dibblego joined
04:36 dibblego joined
04:37 mitchty joined
04:37 splanch joined
04:47 patbecich joined
04:50 takle joined
05:01 meandi_2 joined
05:01 MotherFlojo joined
05:02 monochrom joined
05:10 splanch joined
05:18 obh15 joined
05:29 takle joined
05:46 geekosaur joined
05:48 patbecich joined
05:50 dni- joined
05:52 <obh15> folks, how do you create multiple resource pool and then feed it to spock config?
05:53 davs joined
05:58 splanch joined
05:59 meandi_3 joined
06:19 Gurkenglas joined
06:42 alexelcu joined
06:47 splanch joined
06:52 splanch joined
06:53 splanch_ joined
06:54 <dmj`> @package pool
06:54 <lambdabot> http://hackage.haskell.org/package/pool
07:02 MotherFlojo joined
07:07 kritzcreek_ joined
07:10 davs joined
07:15 <vaibhavsagar> that package is deprecated
07:21 <srhb> Perhaps they were thinking of resource-pool
07:22 Nikotiini joined
07:24 dkeathley joined
07:26 dni- joined
07:28 davs joined
07:33 splanch joined
07:36 davs joined
07:42 takle joined
07:49 Levex joined
07:49 patbecich joined
07:50 eacameron joined
07:54 splanch joined
07:59 davs joined
08:10 geekosaur joined
08:14 Durz0 joined
08:22 zero_byte joined
08:28 Levex joined
08:37 yellowj joined
08:47 myrkraverk joined
08:55 myrkraverk_ joined
09:02 alexelcu joined
09:03 MotherFlojo joined
09:03 <__rgn> is there a way to make ghci not fail in case where expression evaluates to a function for example (No instance for Show)
09:04 <__rgn> i know you can use :t in those cases
09:06 thc202 joined
09:15 t0by joined
09:15 t0by joined
09:16 sherub joined
09:19 takle joined
09:24 Levex joined
09:25 dkeathley joined
09:26 freechips joined
09:26 <freechips> a = 8/2 `mod` 5
09:26 <freechips> a
09:26 <freechips> throws a weird error about ambiguous types...
09:36 andrewhn joined
09:43 mounty joined
09:46 initiumdoeslinux joined
09:51 patbecich joined
09:52 hoffmeyer joined
09:58 <zaquest> freechips, it can't deduce the type, (/) expects Fractional a, but `mod` expects Integral a, and there's no default type for (Fractional a, Integral a), not sure if there exists a sane type that would satisfy this constraint
10:01 azahi joined
10:01 stef204 joined
10:06 eacameron joined
10:13 sherub joined
10:26 dkeathley joined
10:28 hoffmeyer joined
10:32 prophile joined
10:33 AndreasK joined
10:34 dni- joined
10:38 netheranthem joined
10:38 louispan joined
10:39 hoffmeyer joined
10:40 louispan joined
10:44 contiver joined
10:55 Pupnik_ joined
10:58 patbecich joined
11:00 takle joined
11:02 splanch joined
11:04 MotherFlojo joined
11:08 takle joined
11:12 justicefries left
11:13 Zialus joined
11:14 mheinzel joined
11:14 louispan joined
11:16 vaibhavsagar joined
11:16 splanch joined
11:20 splanch_ joined
11:23 MotherFlojo joined
11:33 mojjo joined
11:46 eacameron joined
11:49 hoffmeyer joined
11:56 Croniamental joined
12:01 eacameron joined
12:08 louispan joined
12:11 sherub1 joined
12:20 Pupnik joined
12:26 hoffmeyer joined
12:27 wei2912 joined
12:27 dkeathley joined
12:34 stef204 joined
12:45 Rodya_ joined
12:47 nil_ joined
12:55 eacameron joined
13:00 patbecich joined
13:04 hoffmeyer joined
13:10 pilne joined
13:11 eacameron joined
13:29 eacameron joined
13:32 Deide joined
13:44 nil_ left
14:06 Levex joined
14:07 hoffmeyer joined
14:11 delexi joined
14:12 eacameron joined
14:15 abhiroop joined
14:16 harfangk joined
14:16 <abhiroop> Are there any examples of actually parsing binary data using binary or cereal or attoparsec available? I could not find anything
14:28 dkeathley joined
14:32 Rodya_ joined
14:35 Sose joined
14:36 albertus1 joined
14:41 mojjo` joined
14:44 eacameron joined
14:45 nadirs joined
14:54 argent0 joined
14:59 eacamero_ joined
15:01 patbecich joined
15:05 eacameron joined
15:07 mojjo` left
15:33 Rodya_ joined
15:41 <raduom> I have a method returning IO Something, but the signature is IO (). What would be the elegant way of writing that? I am now using a return () as the last line in the monad, but that seems odd.
15:42 <raduom> { my_method_returning_smth; return pure() } :: IO Something
15:42 <Cale> The last line in the action, you mean
15:43 <Cale> and that's not odd
15:43 <raduom> yes.
15:43 <Cale> er, return pure () is weird
15:43 <Cale> You probably just meant return ()
15:43 <raduom> yeah. it's return ().
15:43 <mheinzel> :t void
15:43 <lambdabot> Functor f => f a -> f ()
15:43 <raduom> that is what i'm looking for :)
15:43 <raduom> thanks.
15:44 <Cale> Another option would just be to change the type signature so that your action returns the thing
15:44 kritzcreek_ joined
15:44 <mheinzel> It's in Control.Monad
15:44 <raduom> Cale yeah. I was just wondering about it :)
15:44 <Cale> I actually kind of dislike the proliferation of functions which care that their argument has type IO ()
15:45 <Cale> as opposed to just accepting an arbitrary IO a
15:45 <Cale> :t forkIO -- I'm looking at you
15:45 <lambdabot> error: Variable not in scope: forkIO
15:45 <Cale> :t Control.Concurrent.forkIO
15:45 <lambdabot> IO () -> IO GHC.Conc.Sync.ThreadId
15:45 simendsjo joined
15:45 <Cale> ^ super annoying
15:45 <mheinzel> Oh yeah, I get what you mean.
15:48 jathan joined
15:48 <Cale> void was actually added kind of apologetically when forkIO's type changed like that.
15:48 <Cale> I don't think it really makes up for it :P
15:55 argent0 joined
15:56 zero_byte joined
15:58 takle joined
16:04 \Mike joined
16:07 tdfirth joined
16:10 tdfirth joined
16:21 yellowj joined
16:28 dkeathley joined
16:31 hoffmeyer joined
16:33 wildlander joined
16:33 azahi joined
16:34 Rodya_ joined
16:47 eacameron joined
16:55 eacameron joined
17:00 albertus1 joined
17:02 patbecich joined
17:03 dejanr joined
17:04 <abhiroop> Are there any examples of actually parsing binary data using binary or cereal or attoparsec available? I could not find anything
17:12 pbrant joined
17:16 vaibhavsagar joined
17:19 mengu joined
17:21 <benzrf> abhiroop: i think cereal is designed to parse stuff it dumped, isn't it?
17:21 jathan joined
17:27 splanch joined
17:28 MotherFlojo joined
17:30 conal joined
17:33 hoffmeyer joined
17:36 Rodya_ joined
17:37 Levex joined
17:39 abhiroop joined
17:47 sherub1 joined
18:03 dejanr_ joined
18:05 m3tti joined
18:09 conal joined
18:23 dejanr joined
18:25 patbecich joined
18:27 patbecich joined
18:27 patbecich joined
18:28 splanch joined
18:28 abhiroop joined
18:29 dejanr joined
18:30 dkeathley joined
18:36 Rodya_ joined
18:40 splanch joined
18:43 abhiroop joined
18:45 splanch joined
18:56 Levex joined
18:59 levex_ joined
19:00 splanch joined
19:04 jmiven joined
19:05 geekosaur joined
19:07 alexelcu joined
19:14 eacameron joined
19:20 hoffmeyer joined
19:25 Levex joined
19:27 abhiroop joined
19:29 dkeathley joined
19:37 Rodya_ joined
19:37 developernotes joined
19:44 stef_204 joined
19:46 Deide joined
19:49 developernotes joined
19:54 developernotes joined
20:00 eacameron joined
20:08 Levex joined
20:09 ego joined
20:17 leothrix joined
20:30 developernotes joined
20:38 Rodya_ joined
20:46 beginningHaskell joined
20:47 <beginningHaskell> How does the box analogy for functors "only go so far"? as claimed in learn you a haskell?
20:47 <qu1j0t3> not all functors are 'boxes' or 'containers'
20:47 <geekosaur> what is the box for ((->) r)?
20:49 mac10688 joined
20:50 <beginningHaskell> I think a functor to Cat
20:50 hvr joined
20:53 eacameron joined
20:56 <Cale> geekosaur: It's possible to think of a function r -> a as being like a big array indexed by values of type r, containing values of type a
20:56 Levex joined
20:57 <Cale> (possibly infinite in size ;)
20:57 <Cale> The box analogy actually works for basically everything, to some extent, but the boxes get really weird.
20:57 <Cale> For example, you can rephrase the State monad like this:
20:58 <Cale> data State s a = Done a | Put s (State s a) | Get (s -> State s a)
20:58 <Cale> and this is now a weird sort of tree-like structure, where Get nodes branch off with s-many children
21:00 <Cale> Well, or you can just stay with the usual s -> (s,a), and think of it as an array indexed by values of type s, where you have both a contained value of type a, and an additional label of type s at each position.
21:01 <Cale> But the free-monad approach makes it clearer how you can think of basically any monad in some sort of container-y fashion. It's just, that might not be the best approach :)
21:04 developernotes joined
21:05 takle joined
21:07 eacameron joined
21:11 eacameron joined
21:12 takle joined
21:16 govg joined
21:19 takle joined
21:20 conal joined
21:21 myrkraverk_ joined
21:26 eacameron joined
21:31 systemfault joined
21:34 eacameron joined
21:37 conal joined
21:39 Rodya_ joined
21:40 vandr0iy joined
21:46 <vandr0iy> Hi haskell beginners! could anybody help me with my first HTTP request? http://sprunge.us/gGeE basically, even if I just imported Network.HTTP.Client, it says that openConnection is not in scope, and same goes for all the HTTP.Client stuff
21:46 srnty joined
21:46 dkeathley joined
21:52 hiratara joined
21:56 <AndreasK> vandr0iy: What lib are you using/where did you find the code example?
21:58 <AndreasK> vandr0iy: I found http-conduit quiet straight forward to use there are examples here: https://haskell-lang.org/library/http-client
22:01 <vandr0iy> I just solved the thing: turns out I was using Network.HTTP.Client instead of Network.Http.Client while following the tutorial on the http-streams package page, which uses the latter
22:02 <vandr0iy> could you recommend me an HTML parsing library, instead?
22:02 <AndreasK> vandr0iy: I used https://hackage.haskell.org/package/scalpel-core recently
22:03 <AndreasK> But really depends on what your goal is, this is more for scrapping
22:05 yellowj joined
22:06 <AndreasK> Not much experience myself with others, but off for today now anyway
22:13 louispan joined
22:23 conal joined
22:29 MotherFlojo joined
22:31 hiratara joined
22:32 Big_G joined
22:33 conal joined
22:35 aarvar joined
22:39 Rodya_ joined
22:42 argent0 joined
22:44 aarvar joined
22:47 dkeathley joined
22:51 malaclyps joined
22:54 eacameron joined
23:18 conal joined
23:26 <Durbley> ive read that the IO type maintains referential transparency. I don't see how. Can someone explain
23:26 <benzrf> Durbley: first, a quick note - "referential transparency" probably isn't really the right term for what you mean
23:26 <Durbley> k
23:27 <Durbley> heres my confusion
23:27 <benzrf> second - can you try to articulate any specific issue? i feel like it might help as a starting point
23:27 <Durbley> imagine I make a function
23:27 <Durbley> Fugg :: Int -> IO String
23:27 <Durbley> I put in an integer, take user input
23:27 <Durbley> and it does like
23:27 <Durbley> "3 fuck!!"
23:27 <Durbley> if I type in "fuck!!" and 3 as input to function
23:27 <benzrf> ah!
23:27 <benzrf> that's *not* how it works.
23:28 <benzrf> evaluating "fugg 3" will result, purely, in a value of type "IO String"
23:28 <Durbley> yes
23:28 <benzrf> nothing will happen from that evaluation
23:28 <Durbley> hm?
23:29 <benzrf> if i evaluate "fugg 3", that will not cause anything to happen
23:29 <benzrf> typing "fugg 3" into ghci *will* make somethign happen, but that's because ghci has custom modifications
23:29 <benzrf> normal haskell evaluation simply results in a value of "IO String", no more and no less - nothing will be printed or asked
23:30 <Durbley> you mean if I type fugg 3 into my program
23:30 <Durbley> it will do nothing?
23:30 <benzrf> roughly.
23:30 <Durbley> ._.
23:30 <benzrf> for example:
23:30 <Durbley> i dont get it
23:30 <benzrf> foo :: Int -> Int
23:30 <benzrf> foo x = 4
23:30 <benzrf> where bar = fugg x
23:30 <benzrf> ^if i evaluate "foo 10", nothing will happen - i'll just get back 4
23:31 <Durbley> okay so
23:31 <Durbley> a value of type IO String
23:31 <Durbley> IO "durr" :: IO String
23:31 <Durbley> right?
23:31 <monochrom> Durbley: You should read my http://www.vex.net/~trebla/haskell/IO.xhtml
23:31 <benzrf> er, there's no data constructor called IO
23:32 <Durbley> what is a value of type IO String
23:32 <jle`> there are several :D
23:32 <benzrf> :t getLine
23:32 <lambdabot> IO String
23:32 <jle`> or are you asking what it represents
23:32 <benzrf> getLine is one value of type IO String
23:32 <jle`> a value of type 'IO String' is a description of a program that, when compiled and executed, produces a string
23:32 <glguy> Durbley: Consider the example: main = do let { p10 = print 10 }; return () -- nothing gets printed, all we did was name the action returned by applying print to 10
23:33 <glguy> if we had: main = do let { p10 = print 10 }; p; p
23:33 <glguy> We get a program that prints twice
23:33 <glguy> if we had: main = do let { p10 = print 10 }; p10; p10
23:34 <glguy> Applying print to 10 didn't print anything on its own, but we can build a larger main action out of this smaller p10 action
23:35 <Durbley> jle`, I think the last thing you typed got through
23:35 <Durbley> i was thinking of getLine as a function
23:35 <Durbley> but at compile time it's just a value
23:35 <benzrf> yup
23:35 <Durbley> only doing anything at runtime
23:35 <Durbley> i think I see
23:35 <Durbley> maybe
23:35 <Durbley> Maybe Understand
23:35 <benzrf> you could imagine that a value of type "IO String" is some code for a shell script
23:36 <benzrf> and if you ran the shell script, it would do some stuff and then output a string
23:36 <benzrf> calculating the code for the script is not the same thing as doing what the script's code says
23:36 <benzrf> evaluating `putStrLn "hello!"' is not the same as printing hello
23:36 <benzrf> given an IO action, it makes sense to talk about *executing* the action - the action describes some things happening
23:37 <benzrf> but the key point is: haskell the language does not give you the tools to execute an action!
23:37 <Durbley> is "getLine" really the best grammar
23:37 <Durbley> what about
23:37 <Durbley> gottenLine
23:37 <Durbley> lol
23:37 <benzrf> no!
23:37 <benzrf> gottenLine would be the line which is the result
23:38 <glguy> getLine is the name of an action that gets lines. It's not the result of getting one
23:38 zero_byte joined
23:38 <benzrf> so in haskell you can write some pure code which spits out a description of things that it wants to happen
23:38 <Durbley> k I think I have dim understanding
23:38 louispan joined
23:39 <benzrf> but the haskell code can't *cause those things to happen* by itself
23:39 <benzrf> when you type "runghc MyProgram.hs", ghc will evaluate the contents of `main' and then do what it says
23:39 <glguy> Durbley: It's important to separate your idea of *functions* (things that have -> as the outer most type) from *actions* (things that have IO as the outermost type)
23:39 <benzrf> but the evaluating part is NOT what makes things happen
23:39 <glguy> Durbley: because they're completely separate concepts
23:40 <benzrf> imagine a computer that's not hooked up to the internet, but which has a human operator who can go use another internet-connected computer
23:40 <benzrf> you can't write a program for the computer that will do internet stuff -
23:40 <jle`> Durbley: btw, you write 'compiletime vs runtime', but that's not the real distinction here. it's "evaluation time vs. execution time"
23:40 <benzrf> but you can write a program for the computer which will print out instructions for the operator, who can come back and type in the result, and the program can figure out more stuff to do from there
23:41 <benzrf> in this analogy, haskell programs are the program on the computer
23:41 <benzrf> you can imagine that a haskell compiler will compile your program and bundle it with an "operator" like that
23:42 <jle`> in haskell, *evaluation* (the act of evaluating pure functions and figuring out what they reduce to or resolve to) is different from *execution* (having a CPU or computer interpret a data structure and executing the actions that it represents)
23:43 <Durbley> i THINK i get this
23:43 <benzrf> :)
23:43 <Durbley> Maybe
23:43 <benzrf> you definitely need to use it a bit before it fully makes sense
23:43 <Durbley> what else has value IO String
23:43 <Durbley> besides getLine
23:43 <benzrf> return "hello"
23:43 <benzrf> :t return "hello"
23:43 <lambdabot> Monad m => m [Char]
23:43 <jle`> well, there's the no-op IO action
23:43 <jle`> 'return x' is a no-op IO action that produces just 'x'
23:43 <benzrf> :t putStrLn "hello!" >> getLine
23:43 <lambdabot> IO String
23:44 <Durbley> :t putStrLn "hello"
23:44 <benzrf> ^an IO action that describes the sequence of printing hello and /then/ getting a line
23:44 <lambdabot> IO ()
23:45 <jle`> Durbley: (>>) is a combinator that lets you make complex IO actions by assembling simpler ones together
23:45 <jle`> sort of like taping together two scripts
23:45 <jle`> to make a longer script
23:45 <Durbley> >> is like *>
23:45 <Durbley> right
23:45 <Durbley> except for monads
23:45 <jle`> well, *> works for monads too
23:45 <jle`> (just to be pedantic :3 )
23:46 <Durbley> got it
23:46 <benzrf> so here's what (>>=) does
23:46 <benzrf> when i say `m >>= f'
23:46 <benzrf> the result of evalauting this expression is a new IO action
23:46 <benzrf> evaluating this is pure
23:46 <benzrf> what the new IO action says is:
23:46 <benzrf> "do m, then take the result and pass it to the pure function f. the result from f will be the next action to take."
23:47 <Durbley> what about
23:47 <Durbley> map f over the result of doing m, then combine the types
23:47 <Durbley> somehow
23:47 <benzrf> that's another way of putting it :)
23:47 <benzrf> if we have
23:47 <benzrf> join :: IO (IO a) -> IO a
23:47 <benzrf> what join will do is -
23:48 <benzrf> the input is a description of effects to perform, resulting in another description
23:48 <benzrf> join will say "do that, then afterward, do what the resulting description says"
23:49 <benzrf> it's like going from "call up joe and ask him what to do next" to "call up joe, ask him what to do next, then do what he says"
23:49 <benzrf> Durbley: what language[s] are you already comfortable with, btw?
23:49 <Durbley> lil Python, Java
23:50 <benzrf> ok!
23:50 <benzrf> one moment!
23:53 conal joined
23:53 <dibblego> functionaljava.org hasa join implemented, but it's repeated for each type constructor, because java disallows the generalisation
23:53 <dibblego> e.g. https://github.com/functionaljava/functionaljava/blob/master/core/src/main/java/fj/data/List.java#L1694
23:54 <benzrf> Durbley: https://gist.github.com/b6f71917b7414f41023dbab7369eb983
23:55 <benzrf> in my "example program", none of the expressions i've written have any effects
23:55 <benzrf> but i can import this module and call main.run()
23:58 <Durbley> very weird
23:58 <benzrf> o=
23:59 <Durbley> cool tho. thanks
23:59 louispan joined
23:59 <benzrf> :)