<    April 2017    >
Su Mo Tu We Th Fr Sa  
 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  
00:00 bydo joined
00:02 Ferdirand joined
00:31 cschneid_ joined
00:33 Ferdirand joined
00:41 Ferdirand joined
00:44 flounders joined
01:06 vaibhavsagar joined
01:07 flounder1 joined
01:12 flounders joined
01:13 dididi joined
01:14 harfangk joined
01:16 dni- joined
01:25 takle joined
01:26 flounder1 joined
01:26 louispan joined
01:34 mariusz89016 joined
01:42 Youmu joined
01:44 acarrico joined
01:46 sherub3 joined
01:53 takle joined
02:08 kadobanana joined
02:09 exferenceBot joined
02:13 hexagoxel joined
02:17 louispan joined
02:22 takle joined
02:26 malaclyps joined
02:33 louispan joined
02:38 yaewa joined
02:39 yaewa joined
02:39 malaclyps joined
02:40 yaewa joined
02:41 moei joined
02:47 sherub3 joined
02:55 meandi_2 joined
03:04 louispan joined
03:05 dni- joined
03:13 cschneid_ joined
03:16 takle joined
03:22 mariusz89016 joined
03:27 ebsen joined
03:28 ebsen joined
03:30 takle joined
04:30 bkboggy joined
04:31 <bkboggy> Getting invalid type signature for the following function: XYmodZ :: (Integer -> Integer -> Integer) -> Integer -> Integer -> Integer -> Integer XYmodZ f x y z = (f x y) `mod` z
04:31 <bkboggy> Would anyone have any idea why?
04:31 mariusz89016 joined
04:32 <bkboggy> Hmm, nevermind, it's something with XYmodZ
04:32 <bkboggy> The name.
04:32 <bkboggy> Yeah, must start with lowercase..
04:33 <bkboggy> Error message should be a bit more descriptive.
04:46 Guest81707 joined
04:46 <glguy> bkboggy: Do you understand what it actually meant when you wrote that line?
04:47 <glguy> It's actually valid syntax to write definitions like that, it just doesnt do what you'd expected
04:47 <bkboggy> glguy, Not sure what you mean, since I was getting an error.
04:47 <bkboggy> glguy, it appears Haskell functions must start with lowercase.
04:48 <bkboggy> And it's not one line, it's two lines.
04:48 <bkboggy> It just looks that way in IRC.
04:48 <glguy> Right, so you can't use that syntax to define XYmodZ, it defines f, x, y, and z
04:48 Ferdirand joined
04:48 <glguy> via the *pattern* XYmodZ f x y z
04:48 mariusz89016 joined
04:48 <lpaste> glguy pasted “for bkboggy” at http://lpaste.net/7054553181761568768
04:49 sherub3 joined
04:49 <glguy> There are type constructors and type variables. When you make a pattern you define the type variables and you match the type constructors
04:49 <glguy> err
04:49 <glguy> There are type constructors and type variables. When you make a pattern you define the type variables and you match the constructors
04:49 <glguy> if you want to introduce new constructors you use data or newtype
04:50 <bkboggy> Oh, you're talking about the Uppercase as first character?
04:50 <bkboggy> Yeah, I've noticed that's used for constructors.
04:50 <glguy> Right, uppercase first letter means that its a constructor
04:50 <bkboggy> Thanks.
04:51 <bkboggy> Is there a huge benefit in using Stack?
04:52 <glguy> Depends who you ask
04:52 <bkboggy> I was trying to watch the video from the haskellbook pair and they're going into this whole deal of how to set up Stack and all the various dependencies, but never mention why.
04:52 takle joined
04:53 <glguy> I've found it useful for setting up a common environment when working on a larger executable across multiple people
04:53 <glguy> I don't use it for library development or small executables though
04:53 <bkboggy> Gotcha.
04:53 <glguy> but you'll find people who use it for everything, too
04:53 <bkboggy> Yeah, my Professor seems to be using it.
04:54 dni- joined
04:55 <bkboggy> glguy, hey appreciate you taking your time explaining in detail what happened with that code.
04:55 <glguy> and delete the word 'type' from my explanation
04:56 <glguy> I tried to go back and delete one, but it turned out I had types on the brain and just littered my sentence :)
04:56 <bkboggy> heh
04:56 <bitemyapp> bkboggy: if compared with cabal sandboxes, it spares having to recompile dependencies reused across multiple projects/packages
04:56 <bitemyapp> We avoided comparing because Haskellers are fractious on this but Stack is currently the most popular option.
04:57 <glguy> Yeah, if you're just learning you'll get by either way, and once you have more understanding of your own situation you can figure out what tools to use
04:57 <bkboggy> bitemyapp, gotcha. I guess if I use Haskell beyond my three-week exposure during this quarter, I'll give Stack a further look.
04:57 <adarqui> about to use hxt for the first time, seems fun
05:05 Guest81707 joined
05:08 yellowj joined
05:24 systemfault joined
05:29 sherub3 joined
05:33 Guest81707 joined
05:39 ali_bush joined
05:39 ali_bush joined
05:58 nick_h joined
06:00 ThomasLocke joined
06:01 yaewa joined
06:05 Guest81707 joined
06:17 ev0lord joined
06:17 <ev0lord> Hi! I needed some help. Im new to haskell
06:17 mariusz89016 joined
06:18 <ev0lord> i want to print am IO(Maybe[Custom])
06:18 <ev0lord> How do I do that?
06:18 <ev0lord> an*
06:19 <jle`> ev0lord: you can turn an IO action that produces a Maybe [Custom] into an IO action that prints it using do notation
06:19 <jle`> do c <- maybeCustomMaker; print c
06:20 takle joined
06:22 <ev0lord> i have the do in a where
06:22 <ev0lord> i get this: Couldn't match type ‘IO’ with ‘Scraper String’
06:23 <ev0lord> code on pastebin: https://pastebin.com/YnnbDYi4
06:24 Ferdirand joined
06:25 <jle`> ev0lord: what library is Scraper from?
06:25 <ev0lord> scalpel
06:25 <ev0lord> for web scraping
06:25 <jle`> the problem is yes, that print blah is IO (), but you're building a Scaper
06:27 <ev0lord> so what do I do?
06:27 <jle`> what do you want to do?
06:28 <jle`> you can't really do IO in the middle of a Scraper action
06:28 <jle`> but you can do it in main, or other IO actions
06:28 <jle`> so you can inspect the result of your scraping
06:29 <ev0lord> thats what i want to do
06:29 <ev0lord> i want to scrape and the see what result i get
06:29 <ev0lord> then*
06:36 dni- joined
06:37 bungoman joined
06:37 <ev0lord> ok got it
06:37 <ev0lord> is there a way to see what the values are for variables? like we have condole.log in js etc
06:37 <ev0lord> to debug the code?
06:38 azahi joined
06:44 <bkboggy> You can't derive from concrete types in Haskell, right?
06:45 <glguy> could you ask that a different way? I don't quite understand
06:47 <bkboggy> Can you derive a custom type from a concrete type?
06:47 <bkboggy> Concrete types being Integer, Bool, etc.
06:50 <glguy> data Custom = ABool Bool | AnInteger Integer ? newtype MyInt = M Int
06:50 <glguy> i suppose those aren't what you mean
06:51 <bkboggy> data MyInt = MyInt deriving (Integer) <-- it doesn't work, but is there a way (maybe I'm missing something).
06:51 <bkboggy> Most languages don't allow it, but I'm checking since it's one of the questions being asked.
06:51 <glguy> ok, no you can't use deriving on a type like that
06:51 <bkboggy> A wrapper is what most people go with in other languages, not sure what the standard is for Haskell.
06:52 <monochrom> I don't understand "custom type" and I don't understand the intention of "data MyInt = MyInt deriving (Integer)".
06:53 <bkboggy> The intention is to answer a question being asked in a lab, so that's the most basic case.
06:53 <glguy> type classes aren't related to inheritance in an oo system
06:53 <jle`> bkboggy: it Integer isn't a typeclass...
06:53 <bkboggy> huh?
06:53 <jle`> bkboggy: what would it even mean to derive Integer
06:53 <jle`> you use 'deriving' to derive instances for typeclasses
06:53 <jle`> like Show, Eq, Read, Ord, etc.
06:54 <jle`> but Integer isn't a typeclass
06:54 <monochrom> Then the lab question is being obtuse.
06:54 <bkboggy> We are asked to write our own types and it asks " Can they have a concrete type? What can you do? "
06:54 <bkboggy> Maybe I'm misreading?
06:54 <jle`> who is 'they'? the students?
06:55 <bkboggy> Our types.
06:55 <monochrom> Yes I believe major misreading and reading too much between the lines and overthinking.
06:55 <jle`> hm, what does it mean to have concrete type
06:55 <bkboggy> monochrom, is it? So, how do you interpret the above.
06:56 <monochrom> Delete "can they have a concrete type?"
06:56 Ferdirand joined
06:56 <bkboggy> Here's the entire thing" Write some types of your own! Can they have more than one type parameter? Can they have a concrete type? What can you do?"
06:56 <glguy> concrete type seems to mean type with kind *
06:56 <monochrom> Just have "Write your own types. What can you do?". So much simpler now.
06:56 <bkboggy> monochrom, that's nice, except for the fact that it doesn't answer the question.
06:56 <glguy> the question uses terminology we don't understand
06:56 <monochrom> "What can you do?", if you answer it exhaustively, supersedes all the other parts.
06:57 <bkboggy> Oh, I am being... well... trying, to be exhaustive.
06:57 <bkboggy> To the extend of my newbish knowledge, of course.
06:57 <bkboggy> extent
06:57 <monochrom> OK, learn everything about "algebraic data types". It is complete.
06:58 <bkboggy> What is complete.
06:58 <monochrom> It completely answers the lab question.
06:59 <bkboggy> Well, I've learned what is being presented and then some more from other resources, "everything" can be a an unbounded thing.
06:59 <bkboggy> In many languages, "everything" may take years. Like I said, I don't know how this applies to Haskell, hence my questions.
06:59 <* bkboggy> moves along.
06:59 <monochrom> I am not going to argue the semantics of "unbounded" but I point out that even the Haskell 2010 Report has only finite length.
07:00 <bkboggy> 329 pages, yeah, I'll make sure that I learn everything in by Tuesday in-between four other classes, my three kids constantly bugging me and my full-time job.
07:00 <bkboggy> Thanks.
07:01 <bkboggy> Anyways... back to study. Thanks for the help.
07:04 thc202 joined
07:05 takle joined
07:07 aarvar joined
07:09 xificurC joined
07:10 hdeshev joined
07:12 <ev0lord> is there a way to see what the values or variables are at runtime? in normal programming, i could just print the values to console.
07:12 <ev0lord> whatever be the type
07:14 moei joined
07:15 <jle`> ev0lord: variables are determined at compile-time, so if you did check, it'd be at compiletime
07:15 <jle`> ev0lord: you can use a typed whole to get ghc to tell you what values are available
07:15 <xificurC> ev0lord: while noone else is answering - a quick search brings up this https://wiki.haskell.org/Debugging . After a quick read I'd first try Debug.Trace.trace
07:16 <hdeshev> make them derive the Show class and just print `show myVal`?
07:17 <jle`> oh, i misinterpreted your question to mean 'see what values are available in scope'
07:17 <xificurC> I think he is saying he wants to print without affecting the type of the function (no IO)
07:17 <xificurC> printf debugging
07:17 <hdeshev> :)
07:17 <ev0lord> thanks!
07:18 <xificurC> since haskell is lazy, I guess even a debug print could change the execution
07:18 <adarqui> Debug.Trace
07:19 <adarqui> i hate doing print debugging though
07:19 <hdeshev> I'd split stuff into small functions and print intermediate results by calling those functions in ghci
07:19 Gurkenglas_ joined
07:20 <adarqui> ya
07:20 <xificurC> does this look OK? https://gitlab.com/xificurC/cis194/blob/master/test/Log.hs or is there a more idiomatic way. Especially the last line
07:26 <adarqui> what's this 3 element list? your type?
07:27 <adarqui> i dno, might be more idiomatic to be an actual data type. data MessageType = MessageType Info Warning Error
07:27 <adarqui> but no idea
07:28 <xificurC> adarqui: it's the first recommneded course from bitemyapp's list - http://www.seas.upenn.edu/%7Ecis194/spring13/lectures.html , homework 2, the data types are defined here https://gitlab.com/xificurC/cis194/blob/master/test/Log.hs
07:28 <xificurC> adarqui: eh, here https://gitlab.com/xificurC/cis194/blob/master/src/L02/Log.hs
07:29 <adarqui> oo
07:29 <xificurC> basically there's a constructor Foo a b c where a, b and c are already instances of Arbitrary
07:29 <adarqui> ya i see now
07:31 takle joined
07:31 prophile joined
07:32 <xificurC> I'm just wondering if there isn't a simpler way to compose then what I wrote, which is already boring at 3 fields
07:32 galderz joined
07:32 mariusz89016 joined
07:33 <adarqui> replacing return with pure might also be more idiomatic. do mt <- arbitrary; ts <- arbitrary; str <- arbitrary; return $ LogMessage mt ts str)] -> liftM3
07:33 <adarqui> grr
07:35 <adarqui> liftM3 LogMessage arbtrary arbitrary arbitrary .. might work
07:35 <xificurC> liftM3, I see, thanks!
07:35 <adarqui> kewl np
07:35 <adarqui> and changing return's to pure's
07:37 <xificurC> adarqui: I copied the returns from here - http://www.cse.chalmers.se/~rjmh/QuickCheck/manual_body.html#14
07:38 <bkboggy> I was given some code as an example of pattern matching: http://lpaste.net/354474 However, I get "Equations for `doMaybeStuff' have different numbers of arguments". Tried a few things, but can't seem to figure out how to fix it. Could someone point me in a right direction?
07:38 <adarqui> ya just change them to pure's from now on, when you do your own code. pure gives you 'more', since it's Applicative
07:38 mariusz89016 joined
07:38 <adarqui> and it's more idiomatic now
07:39 <Akii> bkboggy: doMaybeStuff (Just x) = x + 1
07:39 <adarqui> pretty much everyone hates the 'return' term
07:39 <bkboggy> Akii, thanks!
07:39 <jle`> bkboggy: doMaybeStuff Just x is interpreted as a function that takes two arguments: 'Just' and x
07:39 <xificurC> I wrote the worst but simplest solution to the homework for building the MessageTree and there's a logical error somewhere that I cannot see :) https://gitlab.com/xificurC/cis194/blob/master/src/L02/LogAnalysis.hs#L39 . So I'm having fun with QuickCheck along the way
07:39 <monochrom> Moreover, on even-numbered days, I hate "pure" too, it should be "impure". :)
07:39 <bkboggy> Yep... makes sense now... Been up for the pat 30 hours, so basic things begin to escape me.
07:40 govg joined
07:41 <xificurC> adarqui: what's the "problem" with return?
07:42 <monochrom> It is ambivalent. It carries two orthogonal connotations.
07:42 <monochrom> One connotation is "the answer is ___". The other connotation is of control-flow.
07:43 <monochrom> In Haskell, Monad's return loses the second connotation.
07:44 mthek joined
07:44 <monochrom> But people who are used to imperative languages conflating the two concepts will be surprised.
07:44 <adarqui> ^ and you'll actually enjoy typing 'pure' instead of 'return', for those reasons above.. and because it's sexier
07:45 <xificurC> monochrom: your language is very complex for a non-native but I think I get it - other languages use return for control flow while haskell does not
07:45 <monochrom> No, I actually enjoy "impurify 5".
07:45 <adarqui> 8|
07:45 <monochrom> But only on even-numbered days.
07:46 <monochrom> On odd-numbered days I agree with "pure".
07:46 <adarqui> what do you do on prime days?
07:46 <monochrom> On even-numbered days I infer that you are lifting a pure 5 into an impure surrounding, so you are impurifying, not purifying.
07:47 <MarcelineVQ> I'm pointing everything on all the days
07:47 <monochrom> On prime days I write proofs.
07:47 <adarqui> it's day ~736205 since the earth/universe was created, according to year 2017. when's the next prime day? i'll throw a party
07:47 <jle`> i prefer liftM0
07:48 <adarqui> using hxt, how do i do something like this: runX $ doc >>> css "a" >>> (getAttrValue "href" &&& getText) ... i keep getting an empty list.. if i take away the &&&, and only use getAttrValue, im good
07:48 <adarqui> it'll give me the hrefs
07:48 <adarqui> maybe i need to do some kind of hasText thing, before the getText
07:49 <adarqui> ah i need (deep getText)
07:49 <monochrom> Oh! I know now, on prime days I agree with "pure" but want to improve it to "purely".
07:49 <adarqui> nice!
07:50 <adarqui> there's lots of prime days, if you use day of week, day of month, day of year, etc
07:50 <adarqui> so lots of opportunity for purely
07:50 <vaibhavsagar> seriously though, it should be called impure
07:50 <vaibhavsagar> why is it called 'pure'?
07:51 <adarqui> why should it be called impure instead of pure?
07:51 <vaibhavsagar> it puts a pure value into an impure context?
07:52 <monochrom> See, this is why I have multiple personality on this. I actually understand both sides.
07:52 <monochrom> Suppose you have a converter of type "Ord a => Set a -> [a]" like in Data.Set
07:53 <tuturto> I just wrap things inside burrito...
07:53 <monochrom> You will spend all your life arguing with others over whether it should be called "toList" or "fromSet".
07:53 <vaibhavsagar> ah, so you're saying it's short for "fromPure"?
07:53 <monochrom> And it is the same debate as "pure" vs "impure", because it is really "fromPure" vs "toImpure"
07:54 <monochrom> yes
07:54 <jle`> how about we call it pureToImpure
07:54 <adarqui> that's a good explanation, lmao
07:54 <vaibhavsagar> I think "to" would be a nice name
07:54 <monochrom> Ah but jle`, that can only spawn another debate.
07:54 <adarqui> i have split personalities somewhat.. and it's odd, sometimes i use toList, sometimes i use fromSet, in that example you gave
07:54 <adarqui> and it bugs me
07:55 <monochrom> pureToImpre vs impureFromPure :)
07:55 <adarqui> hah
07:55 <monochrom> And it actually is plausible because you look at "impureFromPure 5" and you have a better adjacency between "Pure" and the pure "5".
07:56 <monochrom> But then you look at the type "a -> f a" and it is in the "pure to impure" direction.
07:56 <vaibhavsagar> from would be good too, but it's longer and is already used in import lists
07:57 <vaibhavsagar> actually no, I'm wrong about that
07:57 <vaibhavsagar> had a python brain fart
07:57 <adarqui> what does "haskell: a purely functional programming language" become
07:57 <adarqui> ie purely
07:58 <vaibhavsagar> the language is still pure
07:58 <vaibhavsagar> it's the runtime that is impure
07:59 takle joined
08:00 <adarqui> ive been programming in haskell for like 3 years and i have literally no idea how anything works
08:02 <jle`> as long as you can write programs, that'sn not a problem :)
08:03 <adarqui> true. but it's frustrating being a plumber trying to create a cathedral
08:05 nil_ joined
08:06 <nil_> Why do we use the symbol '~' for "unifies with" again? What's wrong with plain '='?
08:07 mattyw joined
08:07 <monochrom> I think they want = to be in definitions only.
08:08 <jle`> yeah, == would make much more sense than =
08:08 <monochrom> I.e., "=" to mean "define".
08:08 <monochrom> But I am just guessing, and it is only style, not technical.
08:09 <monochrom> Technically everyone should adopt my style and use ":=" for definitions, "=" for equality conditions.
08:10 <monochrom> f :: (a = Int) => a -> a; f x | x = 0 := 4 | otherwise := 5
08:11 <monochrom> Now it is math. :)
08:11 <monochrom> Or at least Algol.
08:24 <adarqui> in hxt, im using removeAllWhitespace to extract the info from these tags.. but it's breaking things up like <span>blah</span> into '\nblah\n' .. anyone have a quick library to turn this html into somewhat pretty, simple text?
08:25 <LiaoTao> adarqui: Are you parsing HTML without evaluating the DOM?
08:25 <LiaoTao> Sounds like a bad idea
08:25 <adarqui> why? nah im parsing a simple html page
08:26 <adarqui> no dom parsing needed
08:26 <adarqui> it's some oldschool html
08:26 <adarqui> i just want to turn that html into a pretty blob of text
08:26 grdryn joined
08:26 <adarqui> i know something exists, wondering if you guys know of something
08:32 Ferdirand joined
08:34 takle_ joined
08:37 zero_byte joined
08:39 takle joined
08:45 mojjo joined
08:46 ali_bush joined
08:47 Iceland_jack joined
08:49 takle joined
08:52 <adarqui> hakyll's stripTags is a little better
08:54 ali_bush joined
08:54 ali_bush joined
08:54 takle joined
08:58 lithie joined
08:59 <adarqui> i should just allow my app to use html for the time being
08:59 <adarqui> hehehe
09:00 Majiir joined
09:05 Ferdirand joined
09:11 <adarqui> here's a program (in node/js) which does a good job: https://github.com/werk85/node-html-to-text .. i imagine i won't find something on that level, in hs.
09:11 <Cale> Pandoc?
09:11 <Cale> Not sure if it can take HTML as input
09:11 <adarqui> hakyll uses pandoc, im using hakyll for stripTags
09:11 <adarqui> not sure about pandoc th
09:11 <adarqui> o
09:12 <Cale> oh, it can
09:13 <adarqui> pandoc test.html -f asciidoc ... wondering if i could make that better
09:14 <adarqui> similar to this node-html-to-text
09:14 <Cale> You can use pandoc as a Haskell library
09:16 mengu joined
09:22 hdeshev joined
09:26 mengu_ joined
09:32 takle joined
09:35 Ferdirand joined
09:35 merijn joined
09:37 <adarqui> anyone good with hxt? wondering how one would just grab all of the "html" inside <body>
09:38 <adarqui> i mean their getText function gives me all of the text, without any tags
09:46 <adarqui> i stopped using hxt. 2 Text.breakOn's works fine
09:48 Miroboru joined
09:50 takle joined
09:50 <merijn> adarqui: Honestly, HXT seems really complex when you're dealing with messy html (like webscraping)
09:50 <merijn> Personally I'ved used html-conduit a couple of times with reasonable success
09:51 <merijn> Less heavy weight/confusing than HXT, but more reliable than, say, using Text
09:55 <adarqui> cool thanks. ya im using hxt initially just to parse the index file, for anchor tags <a href=..>name</a>. so that works good. then i'm parsing the 'body' just using Text.breakOn, because it's a pretty simple rule.
09:55 <adarqui> never used html-conduit, i've seen it recommended
09:56 <merijn> adarqui: It's pretty easy (if a little bit confusing at first) you can easily do things "grab the content of all "a" tags that are inside a body", etc.
09:58 <adarqui> nice
10:08 Ferdirand joined
10:10 qu1j0t3 joined
10:16 moei joined
10:28 eacameron joined
10:35 mengu joined
10:39 Ferdirand joined
10:46 cschneid_ joined
10:56 Kuros joined
11:00 <nil_> I found this article again <https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/> and I'm confused about this part:
11:00 <nil_> "[Typeclasses] confound two separate issues: specifying how a type implements a type class and specifying when such a specification should be used during type inference."
11:00 <nil_> What's he talking about?
11:01 <merijn> nil_: Lemme see
11:02 <merijn> nil_: Word of warning, that's Robert Harper and he's...notorious for trolling about Haskell's design
11:02 <nil_> That's fine.
11:02 <merijn> He's a smart guy who knows a lot, but he's just mad Haskell won the popularity contest instead of SML, so he likes to complain about minor points in Haskell
11:03 <merijn> nil_: Basically, the complaint seems to boil down too: "To have type inference of classes work, we have to assume that there's exactly one instance per type. However, sometimes there's many conceivable instance for the same type"
11:04 <nil_> I see. That sounds like a fair complaint.
11:05 <merijn> nil_: It is, but having used OCaml's modules they're not "the" solution either
11:05 <Cale> Except that it's not, in that the point of type classes is to specify global conventions about things.
11:05 <merijn> Because they tend to make things verbose
11:05 <merijn> Cale: Well, mixing newtypes to get a different instance you want can be a mess
11:05 <merijn> So I don't think typeclasses are ideal
11:05 <merijn> But then, neither are modules ala ocaml
11:06 <Cale> For example, he complains about the manner in which only one ordering is allowed
11:06 <merijn> And I think typeclasses are, in general, more pleasant to work with
11:06 <Cale> But this property is essential to make data types like Map and Set work.
11:06 <merijn> Cale: Well, with modules (which is Harper's obvious alternative) you'd have your Map module parameterised over an ordering module
11:06 <merijn> So then it'd be fine
11:07 <merijn> But that's a pain to use in 99% of situations :)
11:07 <Cale> Yeah.
11:08 <merijn> Like usual, Robert Harper's complaints about Haskell are technically accurate, but the impact is overstated and he silently glosses over the downsides of his proposed ML solution :p
11:11 Ferdirand joined
11:11 <Cale> I don't think I've really been very upset with type classes in cases where there's multiple entirely reasonable conventions, and we've had to use newtypes to select. Most of the pain points come when the incorrect convention has been selected, and then it's hard to change because so many things rely on it.
11:12 <Cale> Specifically, the Monoid instance for Map is the main one I can think of.
11:13 <Cale> and yeah, you can newtype Map to get a different instance (and we do), but it *is* annoying, and in an ideal world we could just do away with the existing instance. It's just really hard to do that migration, because a lot of code would compile and quietly do the wrong thing if you made that change.
11:15 amir_ joined
11:15 <amir_> Hi guys, can anyone help me with this: How does this type check: (fmap . fmap) sum Just [1, 2, 3]
11:15 <Cale> I'm not sure that modules entirely help that problem either though. If existing code in the wild uses a module specialised in a particular way, you have to specialise it in the same way to use it.
11:15 <Cale> :t fmap
11:16 <lambdabot> Functor f => (a -> b) -> f a -> f b
11:16 <Cale> Note that f t = e -> t is possible
11:16 <Cale> So then fmap :: (a -> b) -> (e -> a) -> (e -> b)
11:16 <Guest34772> so Just :: a -> Maybe a
11:16 <Cale> which is function composition
11:17 <Guest34772> (fmap . fmap) sum :: (Foldable t, Num b, Functor f1, Functor f) => f (f1 (t b)) -> f (f1 b)
11:18 <Guest34772> this i understand but then how "Just" type checks as f (f 1 (t b))
11:18 nick_h joined
11:19 <Cale> f = (->) a, f1 = Maybe
11:19 <Cale> t = []
11:19 <Guest34772> that makes sense, thanks a lot!
11:20 <Cale> no problem
11:20 <Guest34772> in general how do you think about these problems? like for example (.) . (.)
11:20 <Guest34772> took me an hour to figure out how it got its type
11:21 <merijn> Guest34772: Work them out on paper every time you get confused. Over time it becomes easy to quickly do it in your head
11:21 <merijn> Guest34772: Also, judicious use of typed holes :)
11:22 <Guest34772> could you please show me how you do a complicated one: like the own combinator ((.) $ (.)) if it is not too much work of course
11:27 takle_ joined
11:28 ederign joined
11:29 jarshwah joined
11:35 cur8or joined
11:38 jarshwah_ joined
11:41 harfangk joined
11:49 mariusz89016 joined
11:55 mariusz89016 joined
11:58 Gurkenglas joined
12:00 geekosaur joined
12:01 mariusz89016 joined
12:04 takle joined
12:07 eacameron joined
12:07 <Akii> I'm wondering if I could write a Monoid instance for `StateT [e] (ExceptT b (ReaderT d IO)) a`
12:07 <Akii> or at least Semigroup
12:07 mariusz89016 joined
12:08 <Akii> oh that'll be fun
12:10 shayan_ joined
12:14 xificurC joined
12:14 mariusz89016 joined
12:16 <Akii> why would the type class Semigroup require Monoid instances?
12:16 <Akii> ye it doesn't, what are you doing GHC :D
12:17 <Akii> probably default implementation
12:20 mariusz89016 joined
12:22 takle joined
12:22 <Iceland_jack> Akii: yes
12:23 bungoman joined
12:23 <Akii> not quite at the point where I could use this but damn, Monoids are awesome
12:24 <Akii> ha, of course that only works if `a` is also a Monoid
12:24 <Akii> makes sense
12:25 <srhb> Akii: I'm so confused by the naming of your type variables. :-P
12:26 <Akii> random
12:26 initiumdoeslinux joined
12:26 <srhb> Ah. :-P
12:26 <Akii> should've named them s t a b
12:26 <Akii> or smth like that
12:26 mariusz89016 joined
12:28 jarshwah joined
12:28 <adarqui> just noticed a ton of processes.. apparently the processes i'm creating with createProcess, aren't terminating.. i have std_in/std_out set with CreatePipe .. after i do createProcess, i write to std_in's handle, close it, get the output, then do terminateProcess
12:28 <adarqui> any idea why they'd still be hanging?
12:30 <adarqui> i should probably be using waitForProcess
12:31 <merijn> adarqui: Processes always wait until their parents wait() for them
12:31 <adarqui> ya
12:31 <merijn> So presumably they're hanging around as zombies :)
12:32 <adarqui> dno why i was using terminateProcess
12:32 <adarqui> ya
12:32 <adarqui> noobing it up
12:32 <adarqui> need sleep
12:32 <adarqui> 8|
12:32 mariusz89016 joined
12:34 takle joined
12:35 <Akii> xD
12:38 mariusz89016 joined
12:41 takle_ joined
12:44 mariusz89016 joined
12:47 Ferdirand joined
12:47 acarrico joined
12:47 harfangk joined
12:50 takle joined
12:54 oconnorct1 joined
12:57 yellowj joined
13:06 <Akii> I've been ignoring list comprehensions so far
13:06 <Akii> I've a `a` and a `[(b,c)]` and would like to create a `[(a,b,c)]`
13:06 <Akii> sounds like a job for list comprehensions :D
13:06 <Iceland_jack> Akii: Modern Haskell eschews list comprehensions in favour of higher-order functions
13:07 takle_ joined
13:07 <Akii> okay
13:07 <Akii> might just keep continuing ignoring them then xD
13:07 <Iceland_jack> it's good to know how they work though :) they are sometimes better
13:07 <Iceland_jack> > [ (x, y) | (x, y) <- [('a', 1), ('b', 2)] ]
13:07 <lambdabot> [('a',1),('b',2)]
13:07 <Iceland_jack> If you want to add a "False" to each tuple, you write
13:07 <Iceland_jack> > [ (False, x, y) | (x, y) <- [('a', 1), ('b', 2)] ]
13:07 <lambdabot> [(False,'a',1),(False,'b',2)]
13:08 <Iceland_jack> The same thing with functions
13:08 <Iceland_jack> > map (\(x, y) -> (False, x, y)) [('a', 1), ('b', 2)]
13:08 <lambdabot> [(False,'a',1),(False,'b',2)]
13:08 <Akii> right, that looks better than my lambda or any liftAN function I could come up with
13:11 <Iceland_jack> Of course, this can be written in do-notation too
13:11 <Iceland_jack> it is not used often for lists
13:11 <Iceland_jack> but you can :
13:11 <Iceland_jack> :)
13:11 <Iceland_jack> > do (x, y) <- [('a', 1), ('b', 2)]; pure (False, x, y)
13:11 <lambdabot> [(False,'a',1),(False,'b',2)]
13:11 <Akii> I think the list comprehension is the best here
13:11 <Iceland_jack> Yeah
13:12 iAmerikan joined
13:16 wei2912 joined
13:18 netheranthem joined
13:18 ederign_ joined
13:19 takle joined
13:23 pbrant joined
13:25 jathan joined
13:26 mizu_no_oto_work joined
13:26 <Akii> thanks Iceland_jack
13:27 <Iceland_jack> you're welcome Akii
13:27 <Iceland_jack> list comprehensions are quire simple, can I show you some side-by-side examples?
13:27 <Iceland_jack> > [ 2 * x | x <- [1..5] ]
13:27 <lambdabot> [2,4,6,8,10]
13:27 <Iceland_jack> > map (2 *) [1..5]
13:27 <lambdabot> [2,4,6,8,10]
13:28 <Iceland_jack> > [ 2 * x | x <- [1..5], even x ]
13:28 <lambdabot> [4,8]
13:28 <Iceland_jack> > map (2 *) (filter even [1..5])
13:28 <lambdabot> [4,8]
13:28 <Cale> > [(x,y) | x <- [1..4], y <- [x..4]]
13:28 <lambdabot> [(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)]
13:29 <Iceland_jack> The list comprehensions need to give names, Haskellers like to avoid unnecessary names
13:29 <Iceland_jack> > liftA2 (,) [1..4] [1..4]
13:29 <lambdabot> [(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,...
13:29 <Iceland_jack> oops
13:29 <Iceland_jack> misread
13:29 <Cale> > ["hello" | False]
13:29 <lambdabot> []
13:29 <Cale> > ["hello" | True]
13:29 <lambdabot> ["hello"]
13:30 <Iceland_jack> Another benefit is that they can be written in pointfree style
13:30 <Iceland_jack> doubleEven = map (2 *) . filter even
13:30 <Iceland_jack> versus
13:30 <Iceland_jack> doubleEven xs = [ 2 * x | x <- xs, even x ]
13:31 jship joined
13:31 <Cale> > [x | Just x <- [Just 1, Nothing, Just 2, Just 3]]
13:31 <lambdabot> [1,2,3]
13:31 <Akii> that one is interesting
13:31 chlong joined
13:31 <Iceland_jack> It's called "catMaybes"
13:31 <Cale> > [(x,y) | (x:xs) <- tails [1..4], y <- xs]
13:31 <lambdabot> [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)]
13:32 <Iceland_jack> catMaybes xs = [ x | Just x <- xs ]
13:32 <Akii> I know the function but if you pattern match like that normally you get an error
13:32 <Iceland_jack> Akii: List comprehensions are different, a failed pattern match means it gets "ignored"
13:32 <Iceland_jack> If you write it as a let-binding, it will fail
13:32 <Akii> I guess the behaviour is well defined in the context of a list comprehension
13:33 <Iceland_jack> > [ y | x <- [Just 1, Nothing, Just 2, Just 3], let Just y = x ]
13:33 <lambdabot> [1,*Exception: <interactive>:3:51-60: Irrefutable pattern failed for pattern...
13:33 <Akii> where otherwise that would not be possible
13:33 <Iceland_jack> Yes
13:33 <Akii> unless you're inside the Maybe Monad
13:33 <Iceland_jack> for lists a pattern gets translated into (foo (Just x) = [x]; foo _ = [])
13:34 <Akii> (well that would still fail, but there you could just use bind)
13:34 <merijn> Akii: "foo <- bar" inside a list comprehension becomes (basically): "case bar of foo -> ...; _ -> []"
13:34 <mniip> :t [x | x <- return ()]
13:34 <lambdabot> [()]
13:34 <mniip> no MonadComprehensions?
13:37 <Cale> > [(x,y,z) | x <- [1..] | y <- [1..3], z <- [1..3]]
13:37 <lambdabot> [(1,1,1),(2,1,2),(3,1,3),(4,2,1),(5,2,2),(6,2,3),(7,3,1),(8,3,2),(9,3,3)]
13:37 <Cale> We have ParallelListComp though
13:41 earldouglas joined
13:42 yellowj joined
13:51 Ferdirand joined
13:54 kadoban joined
14:08 Denthir_ joined
14:12 lithie joined
14:12 deank joined
14:16 Lokathor joined
14:19 Denthir_ left
14:22 govg joined
14:25 exferenceBot joined
14:36 exferenceBot joined
14:38 carlomagno joined
14:47 contiver joined
14:57 uglyfigurine joined
14:58 mizu_no_oto_work joined
15:08 cschneid_ joined
15:08 Gurkenglas_ joined
15:10 gregman_ joined
15:12 mthek joined
15:15 mariusz89016 joined
15:21 mariusz89016 joined
15:23 exferenceBot joined
15:25 govg joined
15:33 skeet70 joined
15:35 animated joined
15:38 mariusz89016 joined
15:42 contiver joined
15:48 <__rgn> those on vim, which syntax highlighting plugin do you prefer, or the one that ships with vim
15:58 skeet70 joined
16:00 mengu joined
16:00 ederign joined
16:13 Uniaika joined
16:15 aarvar joined
16:15 aarvar left
16:20 cschneid_ joined
16:20 mattyw joined
16:23 rstefanic joined
16:29 takle_ joined
16:30 govg joined
16:31 skeet70 joined
16:32 acarrico joined
16:34 <kadoban> __rgn: I'm just using the default one and it seems fine.
16:35 <kadoban> IIRC the only problem I've ever had with it was with multi-line string constants, which there's a setting somewhere to fix the hilighting of. Not that I use those that often.
16:36 Naim_ joined
16:39 zero_byte joined
16:49 Guest81707 joined
16:54 NeverDie_ joined
16:56 iAmerikan joined
17:10 wildlander joined
17:17 mizu_no_oto_work joined
17:17 sigmundv joined
17:27 moei joined
17:31 madjestic joined
17:35 malaclyps joined
17:37 iAmerikan joined
17:38 mariusz89016 joined
17:40 dni- joined
17:41 delexi joined
17:41 contiver joined
17:42 takle joined
17:43 Zialus joined
17:46 jespada joined
17:48 Gurkenglas joined
17:49 Orion3k joined
17:50 t0by joined
17:50 t0by joined
17:52 takle joined
17:56 mattyw joined
17:59 mizu_no_oto_work joined
18:17 MotherFlojo joined
18:19 MotherFl1 joined
18:19 malaclyps joined
18:22 contiver_ joined
18:31 Amir_ joined
18:33 mac10688 joined
18:34 wildlander joined
18:35 mariusz89016 joined
18:40 contiver joined
18:43 expo873 joined
18:45 Zialus joined
18:46 yellowj joined
18:50 cur8or joined
19:11 for{} joined
19:11 <for{}> hi
19:12 <for{}> guys, how can i print a inside this `newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) }` ?
19:13 <for{}> i wanna be able to print 'a' using show
19:14 <for{}> any useful link would be welcome
19:16 <geekosaur> if and only if m is IO or a stack based in IO, use liftIO
19:16 <geekosaur> http://www.vex.net/~trebla/haskell/IO.xhtml
19:16 myrkraverk joined
19:16 iAmerikan joined
19:28 dni- joined
19:28 RoyalNightGuard joined
19:30 jespada joined
19:33 shayan_ joined
19:41 taksuyu joined
19:51 iAmerikan joined
19:57 colt44 joined
19:58 iAmerikan joined
20:02 bungoman joined
20:03 <for{}> do haskell programmers build their own monad transformers?
20:05 <geekosaur> rarely, aside from sometimes wrapping a stack built from components in a newtype for convenience
20:06 <geekosaur> (and GND-ing the relevant monad classes)
20:08 <for{}> geekosaur, how easy is for a haskell programmer to build a monad transformer from scratch?
20:10 <geekosaur> if you know what it's to do, not dfifficult
20:10 <geekosaur> if you don't know, you need to solve that oen before thinking about any implementation :)
20:11 <for{}> geekosaur, are there elegant alternatives to monad transformers?
20:11 <geekosaur> that's a religious question :)
20:12 hvr joined
20:12 <geekosaur> some folks are in the monad transfoerm camp., others are in the extensible effects camp
20:12 <for{}> im looking for an opinion and im a noob, dont seek debate
20:12 <for{}> which one do you prefer?
20:13 <glguy> There's a debate about how one should structure an effect system, but you can use a monad transform without taking a side on that topic
20:13 iAmerikan joined
20:13 <glguy> There's nothing particular special about "monad transformer", it's just datatype
20:13 nick_h joined
20:14 <for{}> why extensible effects are seen as an alternative?
20:14 <for{}> i mean why do they matter
20:14 <glguy> There's an orthogonal question about how one could structure a program in terms of the effects it has
20:15 <for{}> which one is more popular?
20:15 xsmalbil left
20:16 <geekosaur> tbh that's a silly question
20:16 Ferdirand joined
20:16 <glguy> for{}: You don't need to worry about "effects systems" at all
20:17 <for{}> how useful is to learn more about extensible effects?
20:25 cur8or joined
20:26 iAmerikan joined
20:28 <for{}> thanks
20:32 albertus1 joined
20:33 ali_bush joined
20:33 ali_bush joined
20:33 malaclyps joined
20:39 simendsjo joined
21:11 azahi joined
21:17 dni- joined
21:29 Uniaika joined
21:33 mariusz89016 joined
21:38 Gurkenglas_ joined
21:39 Uniaika joined
21:43 dpren joined
21:43 <adarqui> hi. how can i simplify my "forever alone" haskell line, so that it only has "forever" and "()", and perhaps one infix operator.. ie, forever $ pure () , would be nicer if it was: forever =<< ()
21:51 <* ski> was going to suggest `fix id' ..
21:52 <adarqui> ya that wouldn't be my variation though. you could take credit for that. not trying to steal any1's thunder
21:53 hiratara joined
21:54 <adarqui> that's a great one tho, better than mine
22:05 malaclyps joined
22:06 rstefanic joined
22:31 hiratara joined
22:34 <rstefanic> I feel like I'm either grossly misunderstanding this or it's so obvious that I'm confusing myself. Is a Monad literally just a typeclass that has >>= and return?
22:35 <jle`> rstefanic: yes. and some laws
22:35 <jle`> monad is actually an extremely simple concept
22:35 <jle`> but bad publicity is why people think they are confusing
22:35 <kadoban> rstefanic: Indeed. Not all that exciting after all the fuss, huh?
22:35 <glguy> rstefanic: The additional magic is that the Haskell language knows about this typeclass and will desugar do-notation into operations from the Monad class
22:35 <jle`> maybe if everyone relaized that monads were a very boring concept, you wouldn't look as smart if you claimed to understand them
22:36 <jle`> so people purposefully make monads sound mystical/exciting so they can feel better about themselves
22:36 <rstefanic> Yeah, it's really not that complicated when it's just a typeclass
22:36 <jle`> but monads are pretty boring
22:36 <rstefanic> It's a useful one for sure though
22:36 <rstefanic> So okay.
22:36 <rstefanic> Before Monads were added with the notation, did people just write their own monad typeclass?
22:37 <rstefanic> kadoban: No, it wasn't hahha
22:37 <jle`> people just used specialized functions for each type
22:37 <geekosaur> nobody really thought in terms of Monads aside from Møggi and Wadler, I think
22:37 <jle`> instead of having a unified typeclass
22:37 <jle`> for example, concatMap and (:[]) were both useful functions for lists
22:37 <qu1j0t3> /b 16
22:37 <jle`> even before there was a Monad typeclass to let them be a part of
22:37 <rstefanic> glguy: yeah, i'd much rather write "do" then a bunch of >>=
22:38 <jle`> so each type pretty much defined their own (>>=) and return
22:38 <rstefanic> Oh I see
22:38 <jle`> one day some people realized that there was a common pattern that we can gather into a typeclass
22:38 <jle`> like Ord or Eq
22:38 <jle`> and here we are today
22:38 <rstefanic> That's pretty tedious to rewrite every function so it works with the type you need it to work with for that instance
22:39 <geekosaur> and yet that's what people do in every other language
22:40 <geekosaur> (the Monad pattern is surprisingly difficult to capture in other languages)
22:40 <rstefanic> yeah wow
22:40 <rstefanic> So when were Monads added to Haskell?
22:40 <jle`> well, monads always existed in haskell
22:40 <jle`> but the Monad typeclass...
22:41 <jle`> in 1996, with version 1.3 of the haskell spec
22:42 <__rgn> how did monads exist in haskell before that?
22:42 <jle`> well, Maybe is a monad
22:42 <jle`> List is a monad
22:42 <jle`> and haskell always had lists
22:42 <jle`> and concatMap, and (:[])
22:42 <geekosaur> also anyone *could* have defined the typeclass
22:43 <geekosaur> nothing was added to the language to make class Monad ... possible
22:43 <jle`> list is a monad, whether or not you have a typeclass instance for it or not
22:43 <jle`> reminds me of a stubborn debate about adding Option to java
22:43 <kadoban> Did do notation exist before Monad? Probably not, right?
22:43 <dibblego> Option was added to Java, years before that "debate"
22:43 <__rgn> what makes something a monad if not the typeclass instance and existence of return and >>=?
22:44 <kadoban> I found out last week that C++ just got std::optional in C++17 :-/
22:44 <jle`> sure, s/adding// :)
22:44 <dibblego> lambdas were added to java before java 8 http://javac.info
22:44 <dibblego> Here is Option, written ~2005, vastly superior to what came to exist in the java stdlib many years later, http://www.functionaljava.org/javadoc/4.5/functionaljava/fj/data/Option.html
22:44 <jle`> __rgn: there must be a `a -> m a` function, and a `m a -> (a -> m b) -> m b` function, that follows certain laws
22:44 <jle`> those functions must be possible
22:45 <__rgn> so if >>= is possible for some type, it's a monad even if it has not been implemented by someone
22:45 contiver joined
22:45 <dibblego> along with some other constraints, yes
22:45 <jle`> and return, in a way that they follow certain laws about how they interact
22:46 <jle`> sort of like how integers form a monoid, even though there is no Monoid instance for them in Haskell
22:46 <jle`> integers form several monoids, actually
22:46 <jle`> __rgn: or in a way more relatable to most programmers, integers are "comparable" and orderable in a meaningful way, even if we had no Ord instance for them
22:49 <rstefanic> Well thanks a lot for your inputs. I feel like I built up Monads up to be some huge indecipherable "thing", but they're just a practical way to build your types around functions without having to re-write your functions for each new type
22:49 <jle`> well...what you describe is just typeclasses in general
22:49 <jle`> Ord, Eq, Show
22:49 <jle`> but yes, there are many "generic" functions that are polymorphic for all monads that are very useful
22:50 <jle`> which is one reason why they are a useful abstraction
22:50 <jle`> just like we have functions like 'sort' which are polymorphic for all Ord instances
22:50 <jle`> and binary search trees, which work polymorphically for any key type that is an instance of Ord
22:51 <rstefanic> I see how what I said was just a definition of typeclasses. I guess I meant, it's way to for you to be able to "wrap" and "unwrap" your types without having to rewrite your functions for each new type thatyou want to interact with
22:55 <rstefanic> Would it be fair to say that a Monad is more of a pattern or a set of operations rather than a "thing"?
22:55 <jle`> "technically", the Monad itself is the type constructor
22:55 <jle`> um
22:56 <jle`> along with its operations
22:56 <jle`> so i guess the thing is the set of type constructor + operations
22:56 <jle`> ignore what i said, i didn't really add anything meaningful :)
22:57 <rstefanic> well it's a type constructor with >>= and return, correct?
22:57 <rstefanic> Sorry to keep hammering this, I just want to be sure that I'm understanding this.
22:58 <glguy> rstefanic: It's a type with >>= and return
23:00 <rstefanic> Okay.
23:00 <rstefanic> That's what I was thinking. Thanks for your help. If I have any more questions, I'll probably come back in here ha
23:00 colt44 joined
23:02 zero_byte joined
23:03 malaclyps joined
23:06 dni- joined
23:07 Majiir joined
23:13 ali_bush joined
23:13 ali_bush joined
23:23 cobragoat joined
23:32 louispan joined
23:38 mariusz89016 joined
23:41 malaclyps joined
23:54 <cobragoat> I'm an absolute beginner , trying to use postgresql-simple to load some data and print it to the screen.. would anyone be willing to take a look at this codeblock and help me figure out why I am not getting the desired result?