<    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 theDon_ joined
00:01 <ertes> athan: sounds like something you would do with threads, not callbacks
00:02 infinity0 joined
00:02 <Welkin> athan: maybe you are thinking of javascript
00:03 dedicated joined
00:04 Noldorin joined
00:04 mjora7 joined
00:04 <tobiasBora> Hello,
00:04 infinity0 joined
00:05 <tobiasBora> Can anyone explain me why this very short code : http://paste.debian.net/929372
00:05 <tobiasBora> gives me an error : ‘rawParse’ is not a (visible) method of class ‘RawRead’
00:05 acidjnk22 joined
00:06 whaletechho joined
00:06 zachary joined
00:07 <ertes> tobiasBora: the System.Console.ArgParser module only exports the *class* RawRead, but not its members
00:07 infinity0 joined
00:07 <geekosaur> or, check your argparser package version
00:08 biglambda joined
00:08 <ertes> also consider using a different library… last argparser release is from 2014
00:08 <pacak> So evilll
00:08 <benzrf> tobiasBora: also, that's just "rawParse = Just . rawParse"
00:08 peterbecich joined
00:08 <ertes> tobiasBora: optparse-applicative comes to mind
00:09 <ertes> not overly fond of it, but it's reasonably easy and reasonably powerful
00:10 infinity0 joined
00:11 pandeiro joined
00:13 dan_f joined
00:13 afarmer joined
00:14 <tobiasBora> Ok I'll try it thank you
00:14 uiop joined
00:15 wroathe joined
00:15 <ertes> tobiasBora: here is a tutorial: https://ocharles.org.uk/blog/posts/2012-12-17-24-days-of-hackage-optparse-applicative.html
00:15 eacameron joined
00:15 <ertes> at least for the very basics
00:17 sigmundv joined
00:18 carlomagno joined
00:21 aarvar joined
00:21 MP2E joined
00:22 dylukes joined
00:23 na_th_an joined
00:26 doomlord joined
00:27 e14 joined
00:27 sgronblo joined
00:30 <tobiasBora> ertes: I don't understand how you would define a builder for a "Maybe string", such that if the string is provided, it's "Just mystring", and else it's Nothing
00:30 afarmer joined
00:31 <tobiasBora> Hum, maybe this is the solution http://stackoverflow.com/questions/32422339/how-to-parse-maybe-with-optparse-applicative
00:32 <ertes> tobiasBora: there are many ways, depending on what exactly you need
00:33 <ertes> tobiasBora: example: optional (strOption …)
00:33 platz joined
00:33 chachi joined
00:33 ChaiTRex joined
00:33 zzz joined
00:36 baweaver joined
00:38 plutoniix joined
00:40 dfeuer joined
00:41 mzf joined
00:42 meandi joined
00:42 darlan joined
00:42 starmix_ joined
00:43 <tobiasBora> ertes: I tried that, but I have an error:
00:43 <tobiasBora> The operator ‘<>’ [infixr 6] of a section must have lower precedence than that of the operand,
00:43 nicknovi1 joined
00:43 <tobiasBora> oh my bad
00:43 ^jake^ joined
00:43 <tobiasBora> I forgot to remove a trailing <>
00:44 <tobiasBora> But I've a bug much more mysterious:
00:44 <tobiasBora> ghc: panic! (the 'impossible' happened)
00:45 sigmundv joined
00:45 jordan35332 joined
00:45 <jordan35332> hi
00:45 <jordan35332> i need help on a really simple problem ^
00:45 <jordan35332> https://pastebin.com/MbZaJWGF
00:46 <jordan35332> i dont understand why this short code doesnt work
00:46 eacameron joined
00:46 wroathe joined
00:47 pera joined
00:47 <jordan35332> "No instance for (Num String) arising from the literal ‘20’" what does this even mean
00:47 baldrick joined
00:47 <geekosaur> it means you tried to compare a String to a number of some kind
00:48 tommd joined
00:48 <thimoteus> jordan35332: what do you expect will happen?
00:48 <geekosaur> Haskell does not convert things automatically for you. getLine produces a String; you cannot compare it directly to 20
00:48 <jordan35332> how can i transform the input of getLine to an int
00:48 <jordan35332> oh i see
00:48 baldrick joined
00:49 <geekosaur> > read "20" :: Int
00:49 <lambdabot> 20
00:50 andyhuzhill joined
00:50 acarrico joined
00:51 <jordan35332> alright im updating my code
00:52 <geekosaur> also I would suggest that instead of the `else error ""` you want something like `else return ()`
00:52 Lokathor_ joined
00:53 <tobiasBora> Ouch
00:53 <tobiasBora> I've so much errors that all the lines cannot fit in the Konsole history
00:53 <tobiasBora> I'm not sure to understand this error
00:53 <tobiasBora> Here is my portion of code:
00:53 <tobiasBora> http://paste.debian.net/929378
00:54 vaibhavsagar joined
00:54 <tobiasBora> and the error : Couldn't match expected type ‘Integer -> b4’ with actual type ‘Parser (Int -> Int -> String -> String -> Maybe String -> UserParamScrapeTag)
00:54 <tobiasBora> Possible cause: ‘(<$>)’ is applied to too many arguments
00:54 <jordan35332> @geekosaur thx so much else return () is perfect
00:54 <lambdabot> Unknown command, try @list
00:56 crobbins_ joined
00:56 Stanley00 joined
00:56 nighty-- joined
00:57 crobbins_ joined
00:57 sigmundv joined
00:57 Uakh_ joined
00:57 <geekosaur> tobiasBora, shouldn't that be thing <$> param1 <*> param2 <*> ... ?
00:57 meandi_2 joined
00:57 newhoggy_ joined
00:58 <tobiasBora> geekosaur: Hum well done, thank you!
00:58 tdammers joined
00:58 nikivi joined
00:58 watersoul_ joined
01:00 newhoggy_ joined
01:00 kolko joined
01:00 richi235 joined
01:01 mmachenry joined
01:01 wagle joined
01:01 tctara joined
01:01 baweaver joined
01:01 keri joined
01:01 Disavowed joined
01:02 psmolen joined
01:02 EvanR joined
01:02 brezel joined
01:02 capisce joined
01:02 wroathe joined
01:02 Chousuke joined
01:02 cschneid_ joined
01:02 firef1y joined
01:02 Noldorin joined
01:03 drdo joined
01:03 baetheus joined
01:05 orphean_ joined
01:05 zerokarmaleft joined
01:06 thimoteus joined
01:06 Warrigal joined
01:07 byorgey joined
01:07 byorgey joined
01:09 Disavowed left
01:09 unyu joined
01:11 skeet70 joined
01:12 nikivi joined
01:13 nomicflux joined
01:14 ijp joined
01:14 cschneid_ joined
01:14 Eagle_Erwin joined
01:15 Rodya_ joined
01:15 atomi joined
01:16 __name__ joined
01:17 <jordan35332> my uni forces us to go from python to haskell
01:17 <jordan35332> thats super weird
01:17 <EvanR> could be worse
01:17 <jordan35332> like i do stuff wrong all the time because i think of imperative programming
01:18 <ChaiTRex> Yeah, learning functional programming is hard at first.
01:18 <jordan35332> and there are so many weird rules
01:18 <jordan35332> "there has to be an else statement"
01:18 wroathe joined
01:18 <jordan35332> "the function has to return sth"
01:18 <EvanR> because if then else isnt a statement
01:18 markasoftware joined
01:19 <EvanR> functions always return something in python too
01:19 <monochrom> "function"s
01:19 <jordan35332> yeah but it doesnt give errors when i just wanna run it to check for syntax errors
01:19 <jordan35332> when im not finished u know
01:19 <EvanR> part of functional programming is coming to terms with the hard truth of all these phenomena, and not just misunderstanding them
01:20 codesoup joined
01:20 <monochrom> OK, learn to use "undefined" for checking for syntax errors.
01:20 <jordan35332> i hope i will soon see the pros of functional programming
01:20 <dyreshark> what environment are you writing code in? some of them will tell you about syntax errors as you write your code
01:20 <jordan35332> yeah i guess i will have to do that
01:20 <monochrom> or, error "TODO"
01:20 <EvanR> missing an else *is* a syntax error
01:20 <jordan35332> im using sublime with sublimehaskell
01:21 <jordan35332> but most of the time i compile in the bash
01:21 nikivi joined
01:21 <monochrom> But people who hate to be told "you're wrong" are going to have a hard time with Haskell (generally any statically typed language).
01:22 <EvanR> "i wish i didnt have to close tags in HTML, when i just want to check for syntax errors"
01:22 <jordan35332> nah im fine with that but at the moment all i see is what annoys me about haskell
01:22 <jordan35332> like i cant see the advantages at this point+
01:22 <jordan35332> i just started tho
01:22 <dyreshark> well, sublimehaskell's readme seems to indicate that it should be checking for errors as you code. i dunno why it's not in your case. ¯\_(ツ)_/¯
01:22 <EvanR> i didnt see theadvantage over python in the beginning, but i also didnt see any advantage in python either. it was too hard for me
01:23 bertschn_ joined
01:23 <monochrom> If you're imperatively minded, you won't see advantages, you will only see disadvantages.
01:23 <jordan35332> evan what i mean is that in pythin i sometimes check "if blabla" and haskell tells me "yeah dont do that u have to use if then else"
01:23 <monochrom> The same way because I don't buy OO, every OO advantage you posit is going to be a disadvantage in my eyes.
01:23 <EvanR> if in python and haskell are two different things, thats why
01:23 <EvanR> you are thinking of haskells "when"
01:23 <jordan35332> yeah i didnt know that
01:23 <monochrom> Off-the-top-of-my-hat example being: every method must belong to one and only one class/object.
01:24 lukky513 joined
01:24 Ralith_ joined
01:24 <jordan35332> haskell is fairly new isnt it? i would have to guess without that knowledge id say its very old
01:24 <Hafydd> No, Haskell is quite old.
01:24 <dyreshark> https://en.wikipedia.org/wiki/Haskell_(programming_language)
01:25 <EvanR> its python and haskell are about the same age
01:25 <dyreshark> >first appeared 1990
01:25 OnkelTem joined
01:25 <monochrom> Some people are going to call it an advantage because it means with a good IDE you can just type in the name of a class/object and then press <tab> and then you get a "comprehensive" list of methods.
01:25 <jordan35332> i mean C is from 1972 and it feels much more modern to me than haskell haha
01:25 <taktoa> dyreshark: yeah but miranda was basically the same language and was around since 1985 https://en.wikipedia.org/wiki/Miranda_(programming_language)
01:26 <EvanR> that sounds like a gross misunderstanding of C
01:26 <monochrom> I call it a disadvantage because every really interesting operation is an interaction between several objects and it does not "belong" to one and only one of them.
01:26 <Hafydd> And of Haskell.
01:26 <dyreshark> taktoa: my point ("it's mildly old") still stands :p
01:27 doomlord joined
01:27 <jordan35332> facebook is using some kind of haskell to filter spam, for performance reasons
01:27 <taktoa> dyreshark: yeah I was agreeing and adding that basically-haskell predates 1990
01:28 <monochrom> (To sure, you can correct me by pointing out: I've only described single-dispatch OO, there is multiple dispatch which resolves my issue. But then plain functions are simpler.)
01:28 <jordan35332> so i guess at least its easier to write efficient code in haskell?
01:28 <dyreshark> fair
01:28 <taktoa> jordan35332: I mean, it doesn't have performance issues, but it's not like you write haskell *for* performance
01:28 <* geekosaur> wonders idf "modern" here is supposed to mean "guesses the programmer's intentions, and enjoy the core dump or nonsense behavior when it guesses wrong"
01:28 <taktoa> like unless your measuring stick is python
01:28 <jordan35332> nah lol, compared to python haskell is super fast
01:29 <taktoa> yeah that's what I was saying
01:29 <dyreshark> nah, modern = resilience. it should corrupt random memory when it guesses wrong.
01:29 <dyreshark> this way, your program can keep running
01:29 <EvanR> C sort of took a turn for the unmodern when it came out, lisp was out dynamicing everybody at the time
01:29 <jordan35332> i think the article mentioned that facebook uses c++ layers for the performance sensitvie parts
01:29 <monochrom> Anyway, "a function has to return something" is already an advantage in itself, for its own sake. In my eyes anyway.
01:29 <jordan35332> yeah because you are used to it
01:29 <monochrom> If you already see it as an hindrance, you can give up all hope now.
01:30 <jordan35332> i never give up :p
01:30 <EvanR> jordan35332: its a good opportunity to think logically: if a function literally returned *nothing*, what would happen?
01:30 <jordan35332> it shouldnt be executed imo
01:30 <jordan35332> haskell should just ignore it
01:30 <EvanR> segfault?
01:30 <monochrom> And underlying that is the more fundamental debate "what counts as a function?"
01:30 <EvanR> freeze?
01:31 <jordan35332> i see your point
01:31 <jordan35332> is haskell used for mathematical proofs?
01:31 <jordan35332> "proofs" sry
01:31 <taktoa> it's definitely inspired heavily by mathematics
01:31 <monochrom> No.
01:31 <taktoa> and similar languages are used for proofs
01:31 <jordan35332> alright
01:31 <monochrom> Agda would be used for mathematical proofs. Haskell isn't.
01:31 brezel joined
01:32 Supersonic112_ joined
01:33 hastell joined
01:34 wroathe joined
01:34 eacameron joined
01:35 <EvanR> jordan35332: in a more sophisticated type system you could say your function or your procedure returns type Void (which is a type that has no hope of having a value)
01:35 rkazak joined
01:35 <EvanR> and we could return to the question of what that would mean
01:36 <jordan35332> i think puting void in python is optional, like its the same as if the argument list were empy
01:36 <EvanR> do you mean Nothing, this is not the same thing
01:36 <dyreshark> you're thinking of C, i think
01:36 <jordan35332> oh yeah it could be C
01:37 <EvanR> void means something else in C
01:37 <taktoa> jordan35332: are you talking about a function that returns a value that logically carries 0 bits of information, or are you talking about a function that returns *nothing*?
01:37 <EvanR> that the return value is uninteresting, to the point of it warning you that you didnt ignore it
01:37 <jordan35332> i meant a function that doesnt return anything
01:37 jao joined
01:37 flatmap13 joined
01:38 rblaze1 joined
01:38 <jordan35332> what i meant it in python "void function() and function() is the same thing if there is no return used in this function
01:38 eacamero_ joined
01:38 <Maxdamantus> void in C means there is no value, but it's not used sensibly. They should've just had a unit type that had zero size.
01:38 <taktoa> like the type that represents values containing 0 bits of information is called () and can be thought of as a 0-tuple
01:38 <taktoa> there is exactly one value with the type ()
01:38 <taktoa> it is also called ()
01:39 vi0 joined
01:39 <taktoa> (it's less confusing if you remember how the tuple syntax puns between the type and value level: (0, 0) :: (Int, Int))
01:39 soniku joined
01:40 <Maxdamantus> it's not just a warning if you didn't ignore it; it's an error. You can declare a variable as having `void` type, so you can't pass the result to a function or assign it to a variable.
01:40 <Maxdamantus> can't declare*
01:41 inr_ joined
01:41 <monochrom> Here is another trait advantageous to some people and disadvantageous to the others. Haskell makes equational reasoning (analogous to highschool algebra) easier and running code by hand harder.
01:41 <EvanR> when one line of 100000 is wrong, you dont know which, and the result of the program is a white webpage, you begin to question the utility of "just having haskell (or PHP) ignore something"
01:42 <monochrom> It is an advantage to me. I want to do algebra. I don't want to simulate a computer.
01:42 <monochrom> But most programmers chose to be programmers precisely because they hate algebra. They want to run code by hand to "understand" what the code does.
01:42 <dolio> Does it actually make running code by hand harder?
01:42 <monochrom> Yes.
01:43 <EvanR> since the code is explicit, seems like itd be easier
01:43 <taktoa> monochrom: I'm not convinced that anyone is actually better at being a finite-state-automaton than a graph-reduction-machine
01:43 <Hafydd> [citation needed]
01:43 <taktoa> monochrom: because working memory is limited
01:43 <EvanR> you dont need to remember the invisible dynamic context
01:43 <taktoa> (in your brain)
01:43 darjeeling_ joined
01:43 <taktoa> EvanR: precisely
01:44 calloc joined
01:44 <monochrom> OK, I worded it wrong.
01:45 eacameron joined
01:45 <monochrom> Haskell makes running code by hand look like doing highschool algebra rather than updating a program counter and a stack.
01:45 <monochrom> Better?
01:45 <taktoa> I agree with that.
01:45 <monochrom> Now the math haters have just cause to hate Haskell.
01:46 <EvanR> the question is, what mental model do people use to understand BASIC, perl, ruby, etc
01:46 <EvanR> its not algebra, and its not program countering
01:46 <EvanR> it seems almost mystic
01:46 <monochrom> a program counter and a table of mutable variable values and a stack.
01:46 <taktoa> EvanR: it's State (Map Text Text) :^)
01:46 <vaibhavsagar> monochrom: updating a program counter and a stack is still math, it's just really boring and tedious arithmetic
01:46 <monochrom> Usually the program counter is represented by a human finger.
01:47 <* EvanR> checks the standards for those languages
01:47 <monochrom> vaibhavsagar, you're preaching to a choir member.
01:48 <vaibhavsagar> "preaching to the converted" should be #haskell's motto
01:48 <monochrom> EvanR, the model I just described is explicitly taught by standard curricula.
01:48 tv joined
01:48 <EvanR> it doesnt seem quite right
01:48 <monochrom> In fact you're preaching to a math major and a compsci phd.
01:48 <jordan35332> is it possible to call a function inside an (if then CALL FUNCTION else)?
01:48 <dolio> monochrom: I guess that works for C. Most languages are going to be more complicated than that these days, though.
01:49 <dolio> Have fun writing down all your closures. :)
01:49 zachary joined
01:49 <taktoa> jordan35332: if you want "if-then-else without the else", you probably want Control.Monad.when
01:49 <monochrom> Yes, Java adds a heap. (Well C does too, but not too necessary to make explicit.)
01:49 <jordan35332> nono i want the else
01:49 wroathe joined
01:49 <taktoa> do you want "without the then"
01:49 <jordan35332> its just that i need to execute a function in the "then" part
01:49 bus000 joined
01:50 <taktoa> by function do you mean "something that has side effects"
01:50 <jordan35332> sth that return an int
01:50 <monochrom> Indeed my university explicitly taught the explicit PC x global-vars x stack x heap model. (When it taught Java to 1st year's)
01:50 <ChaiTRex> > let f = (+ 1) in if 1 == 1 then f 1 else f 2
01:50 <lambdabot> 2
01:50 eacameron joined
01:50 <monochrom> (These days it teaches Python instead. But I think same difference.)
01:50 <ChaiTRex> jordan35332: Yes, see above.
01:51 uiop_ joined
01:51 nicknovi1 joined
01:51 <na_th_an> my university still does java heap stack etc. We never really covered functional programmingd
01:51 <jordan35332> parse error (possibly incorrect indentation or mismatched brackets)
01:51 <taktoa> jordan35332: can you define it mathematically? if so, it is a function. if not, it is a program (in Haskell, a program with return type XYZ is denoted by the type IO XYZ)
01:51 <jordan35332> compared to the python interpreter i think that haskells error reports are hard to understand
01:51 flxw joined
01:52 conal joined
01:52 <monochrom> jordan35332, you want to show the actual code you have so far, so we talk concretely not handwavingly "yes you can" "no you can't" "can too" "can not".
01:52 <jordan35332> ok
01:52 naudiz joined
01:52 <jordan35332> https://pastebin.com/HsPDpwVh
01:53 <jordan35332> the part at the bottom is what is important
01:53 mkoenig joined
01:53 <monochrom> You can use "else return ()" or the "when" thing mentioned above.
01:53 <jordan35332> like i call the function flossaufField and i wanna check which argument is used, because there are two different play fields
01:53 <taktoa> jordan: indent "else if" by two spaces
01:54 <monochrom> ("when" is coded up by using "else return ()")
01:54 <taktoa> jordan35332: "return ()" is the IO action that means "do nothing"
01:54 <monochrom> But you can't have "then let a = whatever"
01:54 conal joined
01:54 eacamero_ joined
01:55 <jordan35332> yeah thats the part where im stuck
01:55 <jordan35332> because the second function call depends on the arguemnts used in the first function call
01:55 <jordan35332> @taktoa the two spaces didnt change anything
01:55 <lambdabot> Unknown command, try @list
01:56 <jordan35332> taktoa the two spaces didnt change anything
01:56 <taktoa> jordan35332: yeah the problems run deeper than that
01:56 <jordan35332> its not ur language, but u get what im trying to do?
01:56 <monochrom> Yes.
01:56 <jordan35332> at the end i just wanna know if the field that is chosen has value 1 and if it has value it should say true
01:57 <taktoa> you want `let a = if s == "foo" then Just (foo x y) else if s == "bar" then Just (bar x y) else Nothing`
01:57 <taktoa> and then use `case` to inspect `a`
01:57 <monochrom> if s == "spielfeldA" then print (spielfeldA x y == 1) else if if s == "spielfeldB" then print (spielfeldB x y == 1) else print "You misspelled the name of the spielfeld!"
01:57 <taktoa> that also works
01:58 <monochrom> If you really want to factor out the "== 1", there is a way. But KISS for now.
01:58 <monochrom> Also in a few minutes you will want to read my newly written http://www.vex.net/~trebla/haskell/string-print-show-read.xhtml
01:58 descender joined
01:58 <monochrom> (Consider it a prophecy!)
01:59 <jordan35332> thanks taktoa but it says
02:00 <taktoa> jordan35332: use monochrom's thing
02:00 conal joined
02:00 hucksy_ joined
02:01 sleffy joined
02:01 r1m4n joined
02:01 <jordan35332> im so confused
02:02 <jordan35332> i used yours monochrom
02:02 <jordan35332> but it still says
02:02 noexcept joined
02:02 <jordan35332> parse error (possibly incorrect indentation or mismatched brackets)
02:02 eacameron joined
02:02 <geekosaur> @paste your current code
02:02 <lambdabot> Haskell pastebin: http://lpaste.net/
02:02 cschneid_ joined
02:02 <Koterpillar> you have two "if" there
02:02 <monochrom> It may be sensitive to how you break lines and indent.
02:02 <Koterpillar> "else if if s"
02:02 twopoint718 joined
02:02 <monochrom> Oh hehe, my typo
02:03 <jordan35332> now it works i think
02:04 <glguy> ?type \ a b c d e -> if if a then b else c then d else e
02:04 <lambdabot> Bool -> Bool -> Bool -> t -> t -> t
02:04 Goplat joined
02:05 soniku joined
02:05 <jordan35332> Couldn't match expected type ‘[Char]’
02:05 <jordan35332> with actual type ‘Integer -> Integer -> Integer’
02:05 <EvanR> are we overlooking jordan35332's overuse of Bools?
02:05 <jordan35332> : (
02:05 wroathe joined
02:05 <jordan35332> Probable cause: ‘spielfeldB’ is applied to too few arguments
02:06 <jordan35332> EvanR this is my first haskell program, dont me so strict on me :D
02:08 <jordan35332> i think the problem is that the function parameters are treated as chars and we use them as int
02:09 <monochrom> There is no overuse of Bool.
02:09 <EvanR> just what i suspect from nested if then elses
02:10 <dmj`> is there no intercalate for Builder
02:11 <glguy> dmj`: You'll probably have to mix mconcat and intersperse
02:12 newhoggy joined
02:12 andyhuzhill joined
02:13 newhoggy joined
02:13 <jordan35332> idk why it doesnt work
02:13 <monochrom> Show latest code.
02:15 <jordan35332> https://pastebin.com/fUM4d315
02:15 <jordan35332> there is sth wrong in line 59
02:15 <jordan35332> https://thepasteb.in/p/Z4hPlwo9WzNiG
02:16 urodna joined
02:17 <monochrom> It loads fine in my ghci. No error.
02:17 <jordan35332> yeah it loads fine
02:17 <Koterpillar> you didn't paste any code that has that expression
02:17 <jordan35332> but what happens if you use this:
02:17 Rodya_ joined
02:17 <Koterpillar> ah
02:17 leat joined
02:17 <Koterpillar> you have to refer to it as a string
02:17 <jordan35332> flossAufFeld 1 2 spielfeldA
02:17 <jordan35332> in ghci that is
02:17 <Koterpillar> flossAufField 1 2 "spielfeldA"
02:18 <jordan35332> omg
02:18 <jordan35332> Koterpillar youre right
02:18 <jordan35332> is it possible to make it work when you forgot the " " =
02:18 <jordan35332> ?
02:18 sellout- joined
02:18 <monochrom> This is why it is important to tell people how to reproduce the error, step by step.
02:18 <Koterpillar> yes
02:19 SlashLife joined
02:19 <dmj`> glguy: ah hmm, can’t find a more general interperse than one that operates on lists
02:19 <jordan35332> how?
02:19 <Koterpillar> do you want the answer or hints?
02:19 <dmj`> intersperse* :)
02:19 <jordan35332> ill take the answer its 4:19 am
02:19 <Koterpillar> flossAufFeld x y s = print (s x y == 1)
02:19 <glguy> dmj`: I don't know of one either. I'd have expected an intercalate to work on lists, too
02:19 <glguy> what type do you need to support?
02:19 <monochrom> But then you can't give a string parameter.
02:20 <Koterpillar> yeah
02:20 <jordan35332> Koterpillar instead of "do" ?
02:20 <Koterpillar> you don't need "do" for just one expression
02:20 <monochrom> Actually you need to understand why the double quotes.
02:21 <dmj`> glguy: Data.ByteString.Builder (Builder)
02:21 minancorax joined
02:21 <Koterpillar> jordan35332: in ghci, run :t "spielfeldA" and :t spielfeldA
02:21 <glguy> dmj`: No, in place of the list I mean
02:21 <monochrom> You're hardcoding a string, this is why you need double quotes. The same way you write like s=="xxx", rather than s==xxx.
02:22 <jordan35332> i cant compile it since i added flossAufFeld x y s = print (s x y == 1)
02:22 <jordan35332> blatt1.hs:100:17: parse error on input ‘if’
02:22 <monochrom> If the string comes from user input and you put it in a variable, you don't worry about double quotes.
02:22 <glguy> itercalate :: [a] -> [[a]] -> [a]; so for Building I would expect :: Builder -> [Builder] -> Builder
02:22 <jordan35332> https://pastebin.com/5QQE01Mn
02:23 <glguy> builderIntercalate x y = mconcat (intersperse x y)
02:23 <Koterpillar> jordan35332: that is your _whole_ function now
02:23 <Koterpillar> remove lines 2 and 3 now
02:24 <Koterpillar> you don't need that "else" portion because if you misspell the name of the spielfeld (as I did every time now, lol) the compiler will tell you
02:25 <jordan35332> wow thats awesome Koterpillar
02:25 <dmj`> glguy: oh nice, that’s perfect
02:26 <jordan35332> Koterpillar now it gives the error if you use flossAufFeld 2 3 "spielfeldB" instead of flossAufFeld 2 3 spielfeldB
02:26 <Koterpillar> right
02:26 <jordan35332> there isnt any easy fix to this right?
02:26 <jordan35332> i mean i dont need it
02:26 <Koterpillar> you can go back to where you were
02:26 orhan89 joined
02:26 <Koterpillar> there are ways, but no easy ways
02:26 <jordan35332> nah ill stick with urs ^
02:26 <jordan35332> alright
02:26 <Koterpillar> and do you really need the string version?
02:27 <Koterpillar> you might, if you, for example, take the function names from user/network (which might or might not be a good idea)
02:28 pera joined
02:29 Argue joined
02:30 <ertes> jordan35332: is there any meaning to the number 1 that the spielfeld function returns?
02:30 <ertes> or does that 1 just represent "yes"?
02:30 <jordan35332> there are two players who play that game where u destroy ships
02:30 <monochrom> Haha, underuse of Bool.
02:31 <jordan35332> if there is a boat of player one its 1
02:31 <jordan35332> if there isnt its 0
02:31 <jordan35332> if theres a boat of player two its 2
02:31 <sm> old school! like it!
02:31 SadoqueTD joined
02:31 <ertes> jordan35332: then you may want to define an extra type: data Player = Black | White deriving (Eq, Ord, Show)
02:31 <ertes> jordan35332: type Spielfeld = Int -> Int -> Maybe Player
02:32 <ertes> or… well…
02:32 <ertes> data Spieler = Schwarz | Weiß deriving (Eq, Ord, Show)
02:32 <ertes> =)
02:32 <taktoa> lol
02:32 <jordan35332> i really like this irc channel btw
02:32 <jordan35332> super helpful
02:34 <ertes> jordan35332: also the 'flossAufBrett' function is kind of an anti-pattern… you should just use the individual spielfeld function directly
02:35 <ertes> if the information whether a field is occupied is really the only information you need, then you can just use 'isJust'
02:35 gothos joined
02:35 <jordan35332> some code is like a template we got
02:35 <jordan35332> and we need to fill in a few functions
02:35 <jordan35332> so atm we dont have the freedom to change stuff for this exercise ^
02:36 <ertes> @let data Spieler = Schwarz | Weiß deriving (Eq, Ord, Show); spielfeld 3 _ = Just Schwarz; spielfeld _ 4 = Just Weiß; spielfeld _ _ = Nothing
02:36 <lambdabot> Defined.
02:36 <ertes> :t spielfeld
02:36 <lambdabot> (Eq a1, Eq a, Num a1, Num a) => a1 -> a -> Maybe Spieler
02:36 latro`a joined
02:37 <ertes> > spielfeld 3 7
02:37 <lambdabot> Just Schwarz
02:37 <ertes> > isJust (spielfeld 3 7)
02:37 wroathe joined
02:37 <lambdabot> True
02:37 <jordan35332> look at this
02:37 <jordan35332> sehrSchlechteIdee k x y s = if k == 1 then print (s x y == 1) else if k == 2 then print (s x y == 2)
02:37 <jordan35332> k is now either 1 or 2 (which players turn it is)
02:38 <monochrom> Is that your prof's code?
02:38 <jordan35332> but i need the integer of k not the char
02:38 <ertes> k is a numeric type
02:38 <jordan35332> i think some higher semester students made it
02:38 <jordan35332> parse error on input ‘bombeAuf’
02:38 <monochrom> OK, what ertes is saying is that the author is not using the strength of Haskell.
02:39 <ertes> :t let sehrSchlechteIdee k x y s = if k == 1 then print (s x y == 1) else if k == 2 then print (s x y == 2) in sehrSchlechteIdee
02:39 <lambdabot> error: parse error on input ‘in’
02:39 <ertes> :t let { sehrSchlechteIdee k x y s = if k == 1 then print (s x y == 1) else if k == 2 then print (s x y == 2) } in sehrSchlechteIdee
02:39 <monochrom> I will add that you should demand a refund. :)
02:39 <lambdabot> error: parse error on input ‘}’
02:39 <ertes> oh, come on…
02:40 <ertes> oh, there is no 'else'
02:40 <jordan35332> haha :D
02:40 <jordan35332> i study computer science its just for a semester
02:40 <ertes> ok, then k isn't really anything… the whole thing is a syntax error =)
02:40 <jordan35332> ertes i just forgot the else ^
02:41 <jordan35332> i cant get used to it haha
02:42 <jordan35332> i have a question concerning the style guide of haskell
02:42 <jordan35332> is it like python that there is a char limit of 79 i think per line?
02:42 m0cesta joined
02:43 <m0cesta> sequenceA lazy or not?
02:43 <taktoa> jordan35332: I always obey the 80 character limit, but I'm kind of OCD about that in any language
02:43 <monochrom> Some people say yes, some people say no.
02:43 <m0cesta> WTF?
02:43 <jordan35332> and if so, is it allowed to break a string by starting a new line?
02:43 <taktoa> no, you can't
02:43 <monochrom> I use 89. It's the 21st century already.
02:43 eacameron joined
02:43 <jordan35332> or do i have to use sth like \
02:43 <* geekosaur> uses 96
02:44 <geekosaur> string literals? you can use string gaps
02:44 <taktoa> jordan35332: use `concat ["foooooooooo","baaaaaaaaaar"]`
02:44 <geekosaur> althpugh most people hate them
02:44 <Sornaensis> string gaps?
02:44 <dyreshark> m0cesta: i think that answer wasn't directed at you :)
02:44 ubsan_ joined
02:44 <monochrom> Actually, my answer is good for both questions.
02:45 takle joined
02:45 <m0cesta> dyreshar: ok, and what about question? :)
02:45 <dyreshark> 80 column limit
02:45 <dyreshark> is it a good thing
02:45 <ertes> jordan35332: write code that is readable and appeals to your sense of aesthetics… some people even dispense with layout entirely and uses braces and semicolons everywhere, but it's a rare sight =)
02:46 <taktoa> I mostly see it in GHC's code
02:46 <jordan35332> ok
02:46 markasoftware joined
02:47 <lpaste> geekosaur pasted “string gaps” at http://lpaste.net/354937
02:47 <ertes> even this horrible, ugly, despicable, disgusting style of starting lines with punctuation is popular for some reason
02:47 <MarcelineVQ> ertes: oh you :>
02:47 <taktoa> e.g.: https://github.com/ghc/ghc/blob/master/compiler/hsSyn/Convert.hs#L147-L153
02:48 <monochrom> ertes: There was a time I did that. But only to please the dumber auto-indenter in the old days.
02:48 exferenceBot joined
02:48 <jordan35332> Ipaste ty
02:48 <jordan35332> lpaste ty
02:49 <monochrom> But I don't know why for example SPJ did it.
02:49 <jordan35332> did i just say ty to a bot
02:49 mmachenry1 joined
02:49 <monochrom> Yes.
02:49 <jordan35332> its 5 am
02:49 <jordan35332> ty geekosaur
02:49 Xanather joined
02:49 <geekosaur> heh
02:49 <monochrom> Don't worry, I thank my computers and iPhone all the time.
02:50 <geekosaur> ('sokay, I just tried to reply into my mail window. getting late here too...)
02:50 <monochrom> Especially just before I dispose of them.
02:50 <ertes> when i thank my computer it means that i haven't been out for too long
02:51 <taktoa> reminds me of when people type "ls" into irc :)
02:51 <dyreshark> is it more of a "thank you for your service," or "thank you for going quietly"?
02:51 <jordan35332> whenever i type sudo init 0 i feel like a bad person
02:51 <taktoa> I use sudo systemctl poweroff
02:51 <ertes> i just press the power button…
02:51 <geekosaur> just make sure it's to the correct system...
02:51 <monochrom> for their service and parting sadly
02:51 sgronblo joined
02:52 <taktoa> pressing the power button feels like smothering your computer
02:52 <jordan35332> touch /this
02:52 <jordan35332> cannot touch '/this': Permission denied
02:52 hexagoxel joined
02:52 <ertes> why? it's just another button that triggers just another event
02:52 wroathe joined
02:52 <monochrom> Just last week I said goodbye to 20 floppy diskettes that was OS/2 Warp installation diskettes.
02:53 <geekosaur> enh. on modern systems just pressing it can send shutdown or suspend, it's press and hold that crashes it
02:53 <monochrom> (But don't worry, I already tested that they have gone bad and no longer readable.)
02:53 <jordan35332> press and hold makes me feel like a murder
02:53 <jordan35332> shhh itll be all over soon lmao
02:53 <ertes> if i use it only for powering on, it will be useless 99% of the time, which seems like kind of a waste =)
02:53 peterbecich joined
02:55 eacameron joined
02:55 bydo joined
02:55 cschneid_ joined
02:57 amatecha joined
02:57 MP2E joined
02:58 cschneid_ joined
02:58 kvda joined
03:02 takle joined
03:05 <monochrom> I recommend reprogramming it for Morse code input. :)
03:05 moet joined
03:06 forgottenone joined
03:06 Chong joined
03:06 <Chong> hi everyone
03:06 <Chong> would I be able to get some help with type families
03:07 abel-abel joined
03:07 <Chong> I have a type
03:07 <Chong> newtype Column pgType = Column HPQ.PrimExpr deriving Show
03:08 <Chong> and I just want a type function that turns (Column a) into a (Column Maybe a)
03:09 smillmorel joined
03:11 ddere joined
03:11 <ertes> Chong: your question seems to have a kind error
03:12 <ertes> try to explain the application instead
03:12 jer1 joined
03:13 newhoggy joined
03:13 MrWoohoo joined
03:14 sleffy joined
03:14 <jordan35332> do you remember my ship battle program
03:14 <jordan35332> now I need to change values
03:14 <jordan35332> but i thought haskell would have immutable data types
03:14 andyhuzhill joined
03:14 Sgeo_ joined
03:15 <ertes> jordan35332: state doesn't require mutability
03:15 <ertes> > iterate (\x -> 2*x + 1) 0
03:15 <lambdabot> [0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,2...
03:15 <ertes> this is a stateful list
03:15 <jordan35332> https://pastebin.com/zZJ9hu1H
03:16 <jordan35332> from line 7 to line 43
03:16 blender3 joined
03:16 <jordan35332> when you throw a bomb, i want the field to get the value 0
03:16 <jordan35332> but im not sure if i can do that in haskell
03:16 <c_wraith> You can't change a constant.
03:17 <c_wraith> But you can pass a current state around, and pass a new current state to the next round when needed
03:17 <ertes> jordan35332: exercise: write a function: bomb :: Int -> Int -> (Int -> Int -> Int) -> (Int -> Int -> Int)
03:17 <Axman6> Chong: as far as I can see foo (Column x) = Column x should do what you want, but obviously doesn't make a change to the PrimExpr which you might need
03:17 <jordan35332> yeah i think i redraw the whole board and change only one value -- where the bomb was thrown
03:18 <ertes> jordan35332: this function should return a spielfeld with the given position changed to 0
03:18 <jordan35332> yeah this is what i need
03:18 Rodya_ joined
03:18 otto_s_ joined
03:19 <ertes> jordan35332: try to write it, and keep the following in mind: whenever you see a type of the shape "A -> B -> C" you can read it as "A -> (B -> C)" and vice versa
03:19 <jordan35332> im not sure what that means
03:19 <jordan35332> i guess those arent implications
03:20 <taktoa> jordan35332: it means "a function that takes A and returns a function that takes B and returns C"
03:20 <ertes> it means: in haskell "binary function" and "function that returns a function" are the same concepts
03:20 <taktoa> X -> Y means "a function that takes X and returns Y"
03:20 <ertes> jordan35332: you haven't learned about types i take it?
03:21 <jordan35332> i didnt have a single class on haskell yet
03:21 justanotheruser joined
03:21 <jordan35332> this is the first exercise but the class didnt start yet which is a bit stupid
03:21 <ertes> "::" means "of type"
03:21 <ertes> > 3 :: Integer
03:21 <lambdabot> 3
03:21 felixsch_ joined
03:21 <jordan35332> > "asdf" :: String
03:22 <lambdabot> "asdf"
03:22 <ertes> that's called a type signature
03:22 <ertes> :t "asdf"
03:22 <lambdabot> [Char]
03:22 <jordan35332> okay
03:22 <ertes> :t replicate
03:22 <lambdabot> Int -> a -> [a]
03:22 <jordan35332> but i have no clue how to reassign the whole board
03:22 <ertes> replicate is a function… it takes an Int and an 'a' and return a list of 'a', for all types 'a'
03:23 <ertes> > replicate 4 'a'
03:23 <lambdabot> "aaaa"
03:23 <ertes> makes sense so far?
03:23 <monochrom> Do not "change" the board. Create a new board, based on the old board but also with the updates you want.
03:23 minancorax joined
03:23 <jordan35332> yes
03:23 {emptyset} joined
03:24 flatmap13 joined
03:24 <taktoa> also jordan35332, they actually are implications in a certain sense. in logic, P -> Q means "given P, I can prove Q". a function is a thing that takes a value (a value can be thought of as a proof that a type has at least one inhabitant) and returns another value. so when you write a function of type X -> Y you are basically proving that, if a value of type X exists, then a value of type Y exists.
03:24 wroathe joined
03:24 <jordan35332> yeah i have a maths backround
03:24 <ertes> now the notation "Int -> a -> [a]" may look a bit weird, but there is a very good reason for it: it's actually read like this: Int -> (a -> [a])
03:24 <jordan35332> im a math senior who switched to cs
03:24 <ertes> which would mean: 'replicate' does not actually take two arguments, but it takes one argument of type Int and returns a *function*
03:25 <ertes> would you agree?
03:25 <jordan35332> yeah i guess so
03:25 <monochrom> My http://lpaste.net/52480 is a toy game where you would think I should have "changing" numbers but I don't need "change".
03:25 <ertes> (BTW, you can read the "->" like set notation for functions)
03:26 <ertes> jordan35332: this is actually the truth… 'replicate' is indeed that
03:26 <ertes> :t replicate 4
03:26 <lambdabot> a -> [a]
03:26 <taktoa> yeah (X -> Y) is morally the same as (Y^X) where ^ is superscript
03:26 <ertes> (replicate 4) is the function that takes an 'a' and returns a list of 'a', namely the given argument repeated 4 times
03:26 <ertes> for all 'a'
03:26 <ertes> > (replicate 4) 'a'
03:26 <lambdabot> "aaaa"
03:27 <* taktoa> lambdabot screams
03:27 <ertes> and indeed the notation "replicate 4 'a'" is read as "(replicate 4) 'a'"
03:28 <jordan35332> the exercise sheet tells us to not use list syntax or list functions
03:28 <jordan35332> idk if i can use replicate
03:28 <monochrom> Sure, but they're teaching you how to read types.
03:29 <taktoa> jordan35332: they want you to define it inductively (with recursion)
03:29 <ertes> 'replicate' is a function… not to use list syntax probably means not to use something like "[x,y,z]"
03:29 <ertes> but use (x : y : z : []) instead
03:29 takle joined
03:29 <monochrom> You can surely study replicate and learn some lessons and still not use it in your code.
03:29 <Chong> I'm a newbie with type families
03:29 <Chong> I have
03:29 <Chong> type family ColNul (a :: Column *) :: *
03:29 <Chong> type instance ColNul ('Column a) = Column (Nullable a)
03:30 <Chong> but it gives the error "‘Column’ of kind ‘* -> *’ is not promotable"
03:30 <taktoa> jordan35332: try writing `length` using recursion. then you'll get the flavor of how to write a function like replicate
03:30 <Chong> is there any way around this?
03:31 <Koterpillar> Chong: what's Column, and why don't you want ColNul a = Column (Nullable a) instead?
03:31 jer1 joined
03:32 <jordan35332> i cant do it rn
03:32 <jordan35332> idk
03:32 <Chong> I want to convert a column to a nullable column
03:32 <Chong> newtype Column pgType = Column HPQ.PrimExpr
03:32 <ertes> jordan35332: exercise: write an infinite list of ones
03:33 <ertes> > ones
03:33 <lambdabot> [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1...
03:33 <Chong> so Columns are all actuall the same type
03:33 <ertes> jordan35332: like this one
03:33 <monochrom> It's 5am there and I think you should prescribe sleep rather than moar exercises. :)
03:33 <Chong> ColNul should be more aptly called ColToNullableCol
03:33 <Koterpillar> Chong: so why not ColNul :: * -> *
03:34 <Koterpillar> Chong: ColNul (Column a) = Column (Nullable a)
03:34 <ertes> well, we're in the same time zone apparently, and i'm fully awake… i shouldn't assume that everybody has a messed up sleep cycle like me =)
03:34 hargettp joined
03:34 <MonadHendrix> what timezone is that
03:35 <ertes> CEST
03:35 texasmynsted joined
03:35 <Chong> I can't do that
03:35 <Chong> it's just a syntax error
03:35 <Axman6> Chong: I think you'll need to share more of your code, it appears you trying to make something quite simple more complex than it needs to be, but it might be warranted in the context of the other work you're doing
03:36 harfangk joined
03:36 msko joined
03:37 <Koterpillar> Chong: works for me: type family ColNul (c :: *) :: *; type instance ColNul (Column a) = Column (Nullable a)
03:38 iqubic joined
03:38 <iqubic> Hello guys.
03:38 <iqubic> > show "Hello World"
03:38 <lambdabot> "\"Hello World\""
03:38 <iqubic> What is that weirdness there?
03:38 jamin1001 joined
03:38 mbuf joined
03:39 obadz joined
03:39 <monochrom> Read my http://www.vex.net/~trebla/haskell/string-print-show-read.xhtml for why.
03:39 <Koterpillar> iqubic: lambdabot always applies show to the result
03:39 <Koterpillar> iqubic: otherwise, how can it print the value (which might or might not be of type String)?
03:40 wroathe joined
03:40 <iqubic> Ah, I see.
03:40 <iqubic> So it took my String, and showed it twice.
03:41 <Chong> holy shit
03:41 <Chong> thanks Koterpillar
03:41 <Koterpillar> yw
03:41 <MarcelineVQ> idk about that double show explanation, read requires the escaped \" as well. read and show are typically defined to interperet what you give them in the same way you'd see them in source code. and since " " has meaning to ghc and ghci you need to escape them
03:42 takle joined
03:43 <MarcelineVQ> I suspect monochrom's link will say similar but much more clearly
03:44 calloc joined
03:47 takle joined
03:47 JoshS joined
03:49 <monochrom> This breaks my heart: Between Haskell 1.2 and 1.3, "Import declarations no longer have a renaming clause. Qualified names should be used to handle name clashes."
03:49 <monochrom> But there is also this gem: "n+k patterns are still present, but their use is officially discouraged."
03:50 <monochrom> It took that long to kill n+k patterns :)
03:50 <MarcelineVQ> what was the downside of n+k?
03:50 <iqubic> What is an n+k pattern?
03:51 <ertes> fib (x + 2) = fib x + fib (x + 1)
03:51 <jle`> iqubic: back in the old days, we'd write things like fac (n + 1) = (n+1) * fac n
03:52 <jle`> but it was pretty silly
03:52 sgronblo joined
03:52 jer1 joined
03:52 <jle`> http://stackoverflow.com/questions/3748592/what-are-nk-patterns-and-why-are-they-banned-from-haskell-2010
03:53 <MarcelineVQ> but the same can be done with viewpatterns in an even odder looking way yeah? foo ((+1) -> x) = x
03:53 <MarcelineVQ> are n+k discouraged because it's both weird and not general enough?
03:54 <MarcelineVQ> I guess the difference is you don't have n anymore with that view example
03:55 takle joined
03:55 <MarcelineVQ> nvm, you don't anyway
03:55 minancorax joined
03:56 <geekosaur> n+k is discouraged because it can easily lead to hard to diagnose partial functions
03:57 <MarcelineVQ> hmm, I see that here https://sites.google.com/site/haskell/notes/nkpatterns
03:57 brynedwardz joined
03:57 <ertes> MarcelineVQ: i think that's not the same
03:58 <ertes> foo (subtract 5 -> n) | n >= 5 = …
03:58 <ertes> more like that
03:59 <ertes> at least view patterns support easy binding
03:59 kittyP joined
03:59 <ertes> foo n'@(subtract 5 -> n) = …
03:59 <Axman6> > let foo 0 = 1; foo 1 = 1; foo (pred -> n) = foo n + foo (pred n) in foo 15
03:59 <lambdabot> 987
04:00 splanch joined
04:00 <MarcelineVQ> oh yeah neat so you can 'get the n back'
04:01 <monochrom> https://sites.google.com/site/haskell/notes/nkpatterns is wrong to use the "informal semantics" and "formal semantics". Both of them are not for types, only for what happens when a program is run.
04:01 <ertes> i think the idea of n+k patterns wasn't so bad, but it had weird extra "features"
04:01 <ertes> also it would work much better if we had a Group class
04:02 {emptyset} joined
04:02 haasn joined
04:02 <ertes> hmm, probably not
04:03 <ertes> the way you can write code in curry and mercury is quite nice, which is basically n+k patterns on steroids… i wish we had that in haskell
04:03 <monochrom> Oh yikes, I'm wrong, there is a paragraph saying "These identities all preserve the static semantics".
04:04 biglambda joined
04:06 <ertes> reverse (xs ++ [x]) = x : reverse xs
04:07 soniku joined
04:08 <monochrom> You won't want to know how the compiler does it.
04:08 <MarcelineVQ> too much x rev (\(x:xs) -> xs ++ [x] -> x:xs) = x : reverse xs
04:08 <monochrom> Because if you know, then the logical (pun intended!) conclusion is that time and space are even harder to predict than Haskell's.
04:09 takle joined
04:09 <MarcelineVQ> oops, should be rev
04:09 <MarcelineVQ> also that lambda isn't exhuastive, exit stage left
04:09 <monochrom> Whereas Haskell just requires you to understand lazy evaluation, and once you do, it's pretty invariant across different compilers and different versions...
04:11 <ertes> yeah, sure
04:11 <monochrom> This logic programming nicety requires you to know exactly what heuristics the compiler is using to solve the constraints, what are the complexities of the multitudes of clever constraint solvers, under what brittle condition does the compiler fall back to brute-force search. And it changes every time a new version comes out.
04:11 wroathe joined
04:12 <ertes> the code is still nice though =)
04:12 <ertes> at least for some algorithms
04:12 infinity0 joined
04:13 <monochrom> Whereas predicting Haskell time and space is merely chemistry, predicting logic language time and space is biochem.
04:13 jer1 joined
04:17 LiaoTao joined
04:19 Rodya_ joined
04:19 sproingie joined
04:19 <rotaerk> hmm not really sure how best to format a big chunk of code wrapped in a finally
04:20 <rotaerk> seems like it'd have been more convenient if the arguments hadn't been reversed, such that the final action be specified first
04:20 splanch_ joined
04:22 takle joined
04:22 robotroll joined
04:22 systemfault joined
04:23 <rotaerk> hmm, guess it looks the best if I wrap it in ``
04:23 <monochrom> I sometimes do this. When formatting "x = A `finally` B" (in which A is a do-block and B is a do-block), I indent A by 4, put `finally` on its own line and indent by 2, and B by 4.
04:23 splanch__ joined
04:25 sellout- joined
04:25 vicfred joined
04:26 LiaoTao joined
04:26 <monochrom> Haha there are Coq proofs and others for how STG correctly implements lazy evaluation. https://wiki.haskell.org/Language_and_library_specification#Related_work
04:28 <monochrom> Actually it may be more like: "x = do" 1st line, rest of A below and by 4, "`finally` do" on its own line and by 2, rest of B below and by 4.
04:30 sellout- joined
04:30 <rotaerk> monochrom, thanks
04:33 jer1 joined
04:35 plotnus joined
04:37 biglambda joined
04:37 dylukes joined
04:37 Atrumx joined
04:38 hybrid joined
04:41 andyhuzhill joined
04:42 JuanDaugherty joined
04:42 <Myrl-saki> Hai. I need halp.
04:43 tommd joined
04:43 wroathe joined
04:43 <jmnoz[m]> do you have an appointment?
04:44 <Myrl-saki> lmao
04:44 <Myrl-saki> I'm thinking of a proper type for it.
04:44 <Myrl-saki> foo :: MVar -> IO String -> IO a
04:44 <Myrl-saki> MVar serves as a buffer, IO String as a producer and IO a as a type.
04:45 <tsani> (you're missing a type parameter for your MVar)
04:45 <Myrl-saki> MVar String
04:45 <tsani> Cool
04:45 smillmorel joined
04:45 <tsani> A return type IO a suggests that this runs forever
04:45 xall joined
04:45 <Myrl-saki> Basically, a serial ExtensibleState(think XMonad) thingy.
04:45 eklavya joined
04:46 jhrcek joined
04:47 <JuanDaugherty> unresolved anaphora: the it for which you need halp
04:47 Levex joined
04:49 Usurp1 joined
04:50 <Axman6> Myrl-saki: what is the a?
04:50 splanch joined
04:50 <Axman6> your description doesn't make much sense :\
04:51 wedens joined
04:51 plotnus joined
04:51 <Myrl-saki> You use it like..
04:52 <Myrl-saki> foo buffer (read file) :: Io Int
04:52 <Myrl-saki> IO*
04:52 <Myrl-saki> The reason why there is a buffer there is because if it doesn't match, you add it to the buffer.
04:52 <Myrl-saki> You can have multiple `foo` reading for different types.
04:53 fracting joined
04:54 jer1 joined
04:55 tommd joined
04:58 BartAdv joined
04:59 wroathe joined
05:00 fakenerd joined
05:02 newhoggy_ joined
05:03 splanch joined
05:03 cyborg-one joined
05:06 splanch_ joined
05:06 <ertes> Myrl-saki: why don't you explain what you're trying to do… in your explanation try not to use the words "buffer", "producer" and "lmao"
05:08 <ertes> rotaerk: another option is: (`finally` c) $ do …
05:08 <rotaerk> good point
05:08 <ertes> rotaerk: and if your name happens to be ertes, you might also do this: do Codensity (\k -> k () `finally` c); …
05:08 <ertes> =)
05:08 hazyPurple joined
05:09 soniku joined
05:09 splanch joined
05:10 splanch__ joined
05:11 splanch_ joined
05:11 <Myrl-saki> ertes: foo acc call, `foo` will first check if `acc`, an `MVar String` contains the data it needs. (A type-value tuple), and if it does, then `foo` will return with the value and the tuple removed from acc. Otherwise, keep running `call` and appending to acc.
05:12 <ertes> Myrl-saki: explain the problem, not the solution
05:13 <Myrl-saki> ertes: I did explain the problem. A serial ExtensibleState.
05:13 <iqubic> Well, I'm lost.
05:14 <iqubic> I don't understand that short problem description.
05:14 <Myrl-saki> I guess the proper method is to just have one huge sum type.
05:14 <Myrl-saki> iqubic: Serial. In the Haskell-sense, encoding as a byte stream or whatsover.
05:14 <ertes> i think you're explaining only a small part of the problem, and it doesn't really help in isolation
05:15 <iqubic> Can someone give me an example of a product data type in Haskell?
05:15 <ertes> iqubic: (,)
05:15 jer1 joined
05:15 <iqubic> ertes: Why is that not a sum data type.
05:15 <ertes> iqubic: it is, but it's a trivial one
05:15 <iqubic> I don't really understand the difference there.
05:15 wroathe joined
05:15 unK_ joined
05:15 <jle`> iqubic: http://chris-taylor.github.io/blog/2013/02/10/the-algebra-of-algebraic-data-types/
05:15 <ertes> iqubic: read 'Either' as (+), and (,) as (*)
05:16 <iqubic> How does that help?
05:16 <ertes> iqubic: alternatively: read constructors as summands and fields as factors
05:16 <Myrl-saki> ertes: It's really just extending ExtensibleState. A proper example would be interfacing between server and client.
05:16 <Myrl-saki> ertes: You have a `send :: a -> IO ()` in the client
05:17 <Myrl-saki> ertes: And `recv :: MVar String -> IO String -> IO a` in the server.
05:17 Maxou joined
05:17 <Myrl-saki> That's mixing some typeclasses.
05:17 <iqubic> Myrl-saki: "Extending and Extnsible state" seems like a tautology.
05:17 mjora7 joined
05:17 <ertes> Myrl-saki: like a concurrent queue?
05:17 <Myrl-saki> ertes: Concurrent in the sense of multiplexing?
05:17 arctictern joined
05:18 <ertes> Myrl-saki: in the sense of "can be written to and read from from multiple haskell threads"
05:18 <Myrl-saki> ertes: Ah nah.
05:18 <Myrl-saki> ertes: The MVar there was for state.
05:18 keutoi joined
05:18 jmnoz[m] joined
05:18 <Myrl-saki> s/MVar/IORef/g
05:18 <Myrl-saki> My mistake.
05:19 <ertes> ok, now it makes slightly more sense… now why is it mutable state? why is it not just… well… state?
05:19 <Myrl-saki> ertes: Well.
05:20 <Myrl-saki> ertes: I guess it's because the type system is not expressive enough, or so.
05:20 Rodya_ joined
05:20 <Myrl-saki> ertes: I'd totally prefer `:: IO String -> IO a`, where `IO String` would preserve state if "reading" fails.
05:20 <Myrl-saki> ertes: But we can't express that in the type system. So instead, we append it to the buffer.
05:21 <ertes> Myrl-saki: i'm at a loss… i have no idea what you're trying to do… so you're reading, say, from a file and updating some state based on the data read, and if reading fails, you want to rewind the state to some earlier one?
05:21 <iqubic> So a rational number of the form (a % b) is a product type?
05:22 <Myrl-saki> ertes: I think I have to give an actual example.
05:22 <Axman6> iqubic: yep
05:22 <ertes> iqubic: well, it is internally
05:22 <iqubic> ertes: What do you mean?
05:22 <ertes> iqubic: it's a type with two fields internally: a numerator and a denominator
05:22 <Myrl-saki> ertes: Let me write up a quick program.
05:22 <Myrl-saki> Err... "program.
05:22 <ertes> Myrl-saki: yeah, that would be helpful
05:23 abb4s joined
05:23 <ertes> iqubic: the idea of products and sums is that types form a commutative semiring w.r.t. isomorphisms
05:24 <iqubic> Right. I understand that.
05:24 <Axman6> iqubic: they're porduct types in the sense that: () can be thought of as 1, Bool can be thought of as 2 (it has two constructors, 1 + 1), Maybea can be thought of as a + 1 (it has as many inhabitants as a, plus the Nothing constructor). Either a b is a + b because it has as many inhabitants as a plus as many inhabitants as b, and (a,b) is a * b, because it has as many inhabitants as all combinations of the inhabitants of a and b
05:24 <ertes> iqubic: a type like (Either A B, Either A C) can be read as (A + B) * (A * C)
05:24 <ertes> whoops
05:24 <ertes> (A + B) * (A + C)
05:24 armyriad joined
05:25 <iqubic> So a function of type (a -> b) is a product type? Is that correct?
05:25 <iqubic> Because each value of a could map onto any one of the values of b.
05:25 <ertes> it is a product type, but a special one: b^a
05:25 <Axman6> a -> b is actually b^ a
05:25 <Axman6> b^a
05:25 <iqubic> Why do you say that?
05:26 <iqubic> Oh wait, I just explained that.
05:26 <iqubic> LOL
05:26 <ertes> iqubic: Bool -> Integer ≃ Integer^Bool ≃ Integer^2 ≃ (Integer, Integer)
05:26 <iqubic> ertes: Right. If f1 :: Bool -> Interger then we have (f1 True, f1 False)
05:27 <Axman6> it basicaslly counts "how many possible functions can have the type a -> b"
05:27 <ertes> iqubic: yeah
05:27 <iqubic> I actually know how to write the iso for that.
05:27 keutoi joined
05:27 <ertes> iqubic: exercise: data Lens a b = Lens (a -> b) (b -> a -> a)
05:28 <iqubic> Sure.
05:28 <iqubic> I know what a lens is.
05:28 <ertes> show why this is isomorphic to: newtype Lens a b = Lens (a -> (b, b -> a))
05:28 <Axman6> there's a whole series of exercises around that type if you're interested
05:28 <jle`> iqubic: don't worry about what Lens is, just think of it as an arbitrary name
05:28 <ertes> iqubic: ^ that's the exercise
05:28 <iqubic> How can you do it?
05:28 <ertes> iqubic: use the laws of semirings
05:28 vaibhavsagar joined
05:29 <jle`> might as well be Foo a b = Foo (a -> b) (b -> a -> a), and Foo a b = Foo (a -> (b, b -> a))
05:29 <ertes> iqubic: commutative semirings that is
05:29 <iqubic> The the laws of WHAT NOW?
05:29 <ertes> iqubic: associativity, commutativity, distributivity
05:29 <Axman6> https://github.com/tonymorris/lets-lens if you're interested, the first exercise is build around the Lens type above
05:29 <taktoa> ertest is saying to prove b^a * (a^a)^b = (b * a^b)^a
05:29 <jle`> iqubic: start with the first one being (a -> b, b -> a -> a
05:30 <jle`> convert it to your familiar algebra language
05:30 <iqubic> Axman6: You don't need to give me a lesson on lenses, I know what those are.
05:30 <ertes> iqubic: let me give you a shorter version of the same exercise: prove: ∀ a b. (a -> b, b -> a -> a) ≃ a -> (b, b -> a)
05:30 <iqubic> Not possible. Sorry.
05:30 sgronblo joined
05:30 wroathe joined
05:30 <jle`> iqubic: convert it to your familiar algebra symbols if you're more comfortable with that
05:31 <jle`> iqubic: what is (a -> b, b -> a -> a) ?
05:31 <iqubic> I don't know how to do that. Sorry.
05:31 <ertes> iqubic: start by converting (->) to (^) and (,) to (*)
05:31 <jle`> you were just doing it fine earlier :)
05:31 <iqubic> I was?
05:31 <iqubic> How?
05:31 <Myrl-saki> ertes: http://ix.io/rPg
05:31 <jle`> iqubic: you were able to see that (a -> b) as b^a
05:31 <jle`> and that (a, b) was a + b
05:31 <jle`> er, a * b
05:31 <iqubic> Oh, yeah I was
05:31 <abb4s> hey every body i have a simple lookup function but it give a error about "‘v’ is a rigid type variable bound by the type signature for lookup ..." .source and error : https://paste.ubuntu.com/24458506/
05:32 <jle`> mhm. you already showed that you know enough to do this
05:32 <iqubic> I'll try to convert (a -> b, b -> a -> a)
05:32 <abb4s> im new in haskell thankyou if you can help me
05:32 <jle`> abb4s: the error is actually one line above that one
05:32 <jle`> 'Cannot match type `v` with `Maybe v`'
05:32 <iqubic> (,) is a sum type? I thought ertes said it was a product type
05:32 <Myrl-saki> ertes: The typeclasses there are either (a) not complete; or (b) wrong.
05:32 <ertes> Myrl-saki: and server and client are on different machines? that's what i take from the Serial constraint
05:32 <jle`> iqubic: it is a product type, i mentioned that i made a typo :)
05:32 Chousuke joined
05:33 <iqubic> Ah, I didn't see that.
05:33 <Myrl-saki> ertes: Well, the only requirement is that they're different programs.
05:33 <jle`> abb4s: the line you pasted tells you where 'v' comes from, but the actual error is that you are giving a 'v' when it's expecting 'Maybe v'
05:33 <jle`> abb4s: are you familiar with Maybe ?
05:33 pyrtsa joined
05:33 <ertes> iqubic: you can use regular equational reasoning, except that you're not using the equation symbol, but the isomorphicness symbol =)
05:33 Costar joined
05:34 <iqubic> What is the isomorphicness symbol?
05:34 <ertes> Myrl-saki: or that
05:34 <iqubic> And what am I trying to prove?
05:34 <iqubic> I lost that.
05:34 <Myrl-saki> ertes: Mhm.
05:34 <ertes> iqubic: there is one in the exercise i gave you =)
05:34 <ertes> iqubic: the last version
05:34 <jle`> prove that (a -> b, b -> a -> a) is the same as (a -> (b, b -> a))
05:34 <iqubic> I have no idea how to type that isomorphicness symbol on my machine.
05:34 <jle`> sorry i probably shouldn't be saying anything
05:34 xtreak joined
05:34 <abb4s> jle`: it say i should do some thing like this : lookup :: Eq k => k -> [(k,Maybe v)] -> Maybe v
05:34 <ertes> iqubic: just use "~" or something… it's not terribly important
05:35 cschneid_ joined
05:35 <iqubic> jle`: It's fines.
05:35 <ertes> iqubic: it's just important to keep in mind that those aren't *equal*, but just *isomorphic*
05:35 <taktoa> iqubic: the exercise is basically prove that b^a * (a^a)^b = (b * a^b)^a using only the commutative semiring laws
05:35 jer1 joined
05:35 <jle`> aka, the things you learned in 8th grade algebra
05:35 <jle`> abb4s: your original type seems reasonable
05:36 <jle`> abb4s: it's the stuff you're doing in your lambda that is ill-typed
05:36 <ertes> iqubic: start by converting (->) and (,) notation to your more familiar symbols
05:36 <jle`> try pulling it out as a helper function
05:36 <iqubic> ertes, I'll do that.
05:36 <Myrl-saki> a -> b -> c ~ b -> a -> c
05:36 <jle`> abb4s: lookup k l = foldr f Nothing l
05:36 leat joined
05:36 <jle`> what would the type of 'f' be ?
05:36 <iqubic> a -> b ~ b^a
05:37 <iqubic> (a, b) ~ a * b
05:37 <ertes> iqubic: yeah
05:37 <abb4s> jle`: IT is a function : foldr :: (a -> b -> b) -> b -> [a] -> b
05:37 suppi joined
05:37 <Myrl-saki> b^a * (a^a)^b = b^a * (a^b)^a = (b*a^b)^a
05:37 <Myrl-saki> I think?
05:37 <jle`> abb4s:i mean, the function 'f'
05:37 <jle`> in what i wrote
05:38 <jle`> foldr (some function) Nothing l
05:38 <jle`> what is the type of "some function", here?
05:38 <taktoa> Myrl-saki: I would expand out the first step into two steps by using (X^Y)^Z = X^(Y * Z) and the commutativity of *
05:38 <Myrl-saki> taktoa: Ah
05:38 <Myrl-saki> True.
05:38 <Myrl-saki> That also make
05:38 <Myrl-saki> a -> b -> c ~ (a, b) -> c
05:38 <Myrl-saki> :D
05:38 <ertes> please try not to spoil it for iqubic, if you know the answer =)
05:38 <taktoa> yep :)
05:39 biglambda joined
05:39 <abb4s> jle`: you mean the data type of return value ??
05:39 newhoggy joined
05:39 <jle`> abb4s: you have `foldr (blahblah) Nothing l
05:39 <jle`> what is the type of blahblah?
05:39 <jle`> is it Int -> Bool?
05:39 <jle`> is it Char -> (String, Double) ?
05:41 <jle`> every value in haskell has a type
05:41 <iqubic> Guys, stop spoiling the answer for me.
05:41 <ertes> Myrl-saki: so it is about concurrent state, as well as IPC
05:41 <iqubic> Anyways I see what a -> b -> c ~ (a, b) -> c
05:41 <abb4s> jle`: thank you dude , it is solved , the type should be f::a->b->Maybe b and i dont have care for it
05:42 <ertes> iqubic: prove it
05:42 <iqubic> f a b c = f (a, b) c
05:42 <iqubic> Or not that.
05:42 <jle`> abb4s: not quite
05:42 <jle`> abb4s: in the function input for foldr, the second argument and the result type should be the same type
05:42 <jle`> it's (a -> b -> b) for some a and b
05:43 <jle`> so in your case, it can't be (a -> b -> Maybe b)
05:43 newhoggy_ joined
05:44 <jle`> it should actually be (a -> Maybe b -> Maybe b) :)
05:44 <abb4s> jle`: you are right , but it works
05:44 quchen joined
05:44 <ertes> abb4s: you may be interested in my foldr tutorial: http://ertes.eu/tutorial/foldr.html
05:45 <abb4s> jle`: the source : https://paste.ubuntu.com/24458566/ , so why it works ??
05:45 <abb4s> !!
05:45 <iqubic> a -> b -> c ~ (c^b)^a
05:45 splanch joined
05:46 <jle`> abb4s: let's look at the types of everything going on
05:46 <abb4s> ertes: thank you
05:46 <iqubic> (a, b) -> c ~ c^(a * b)
05:46 <jle`> abb4s: foldr :: (a -> b -> b) -> b -> [a] -> b
05:46 <jle`> your list here is [(k,v)], so a ~ (k, v)
05:46 wroathe joined
05:46 <jle`> so you have foldr :: ((k, v) -> b -> b) -> b -> [(k, v)] -> b
05:46 <abb4s> yes
05:46 <jle`> your result type is 'Maybe v'
05:46 <jle`> so b ~ Maybe v
05:47 <iqubic> (c^b)^a = c^(a * b)
05:47 <iqubic> a -> b -> c ~ (c^b)^a
05:47 <iqubic> (a, b) -> c ~ c^(a * b)
05:47 <iqubic> (c^b)^a = c^(a * b)
05:47 <jle`> abb4s: so you have foldr :: ((k, v) -> Maybe v -> Maybe v) -> Maybe v -> [(k, v)] -> Maybe v
05:47 <iqubic> There. That proves that.
05:47 <jle`> abb4s: so that actually matches the function you wrote
05:48 <jle`> abb4s: the function you wrote was ((k, v) -> Maybe v -> Maybe v), so that's why it typechecks :)
05:48 <iqubic> can we get back to my isomorphism puzzle?
05:48 <jle`> abb4s: in `\(k2,val) y -> if k1==k2 then Just val else y`, k2 :: k, val :: v, and y :: Maybe v
05:48 dm3 joined
05:48 <iqubic> I figured out that a -> b -> c ~ (a, b) -> c
05:48 <ertes> iqubic: sure, go ahead
05:49 <jle`> abb4s: in your if/then/else statement, you return (Just val :: Maybe v) if the keys match, or (y :: Maybe v) if they don't. success!
05:49 <jle`> abb4s: but note that this behavior is a bit different than 'lookup' usually behaves or is expected to behave
05:49 <iqubic> I got that far. Not sure where to go next though.
05:49 <jle`> abb4s: your implementation typechecks, but the behavior might not be what you want
05:50 <jle`> er actually, wait, this might already be ok, nvm :)
05:50 <abb4s> jle`: becuase we dont want Maybe v as return data type for lookup ? yes ?
05:50 <jle`> you do want Maybe v as the result of lookup
05:50 <jle`> you're good
05:50 <jle`> i just misread something :)
05:51 takle joined
05:51 <ertes> iqubic: b^a * (a^a)^b ≃ (b * a^b)^a
05:51 <ertes> iqubic: for all a, b
05:51 <iqubic> Sure.
05:51 <ertes> iqubic: this is the original exercise translated into (*) and (^)
05:52 <iqubic> And I understand the translation.
05:52 SlashLife joined
05:52 <abb4s> jle`: all is becuase of returning Nothing , i want to if lookup fail then return Nothing , so i has to return all as Maybe v , is there another solutoin for it ?
05:52 <jle`> abb4s: this is the typical way it is done
05:52 <ertes> iqubic: (b * a^b)^a ≃ b^a * (a^b)^a -- (^) distributes over (*)
05:52 <jle`> abb4s: you could also define a version that finds *all* matches, as well
05:52 <iqubic> Sure
05:53 <ertes> iqubic: (a^b)^a ≃ a^(b*a) -- exponential law
05:53 <jle`> lookupAll :: Eq k => k -> [(k, v)] -> [v]
05:53 <abb4s> jle`: how ?
05:53 <iqubic> ertes: where next?
05:53 <ertes> iqubic: b*a ≃ a*b -- commutativity
05:53 <jle`> instead of returning `Maybe v` (zero or one result), you can return `[v]` (any number of results)
05:54 <iqubic> Right, and then you just undo the exponential law you just did.
05:54 <iqubic> And that's that.
05:54 <ertes> iqubic: (a^b)^a ≃ a^(b*a) ≃ a^(a*b) ≃ (a^a)^b
05:54 <abb4s> jle`: so what happen if lookup fail ? it just return empty list ?
05:54 sgronblo joined
05:54 <ertes> iqubic: which is basically a prove that 'flip' is an isomorphism
05:54 <jle`> yes; it'll return an empty list if there are no matches
05:54 <ertes> s/prove/proof/
05:54 <iqubic> Yeah. It really is.
05:55 <iqubic> Now can you bring it all together?
05:55 hazyPurple joined
05:55 <abb4s> jle`: you are right ! :) really thank you
05:55 <jle`> no problem!
05:55 ccomb joined
05:56 <ertes> iqubic: to sum up: (b * a^b)^a ≃ b^a * (a^b)^a ≃ b^a * a^(b*a) ≃ b^a * a^(a*b) ≃ b^a * (a^a)^b
05:56 <iqubic> Right.
05:56 jer1 joined
05:56 hpd joined
05:56 <ertes> i have left out quite a few details, which would be required in a formal proof, but it's good enough
05:56 <iqubic> Can I have another excercise like this? Took me a bit to understand what you wanted me to do.
05:57 <iqubic> I'd like to try the next one all on my own though.
05:57 <ertes> iqubic: easy or challenging?
05:57 <jle`> what does `(a + b)^2 = a^2 + 2ab + b^2` mean, in types? and, can you write the isomorphism it implies?
05:58 Sampuka joined
05:58 <ertes> iqubic: jle` actually already give you the easy one i would have given you, so try that next =)
05:59 <ertes> *gave
05:59 <iqubic> (a + b)^2 is (a, b) -> Bool
05:59 <jle`> almost
05:59 <iqubic> That's not quite right?
05:59 <iqubic> I thought it was.
06:00 <Koterpillar> iqubic: check with 1^2 or 0^2
06:00 <jle`> iqubic: (,) is a product, right?
06:00 <jle`> and a -> b is b^a, right?
06:01 <iqubic> wait, (a + b)^2 is Bool -> Either a b
06:01 <jle`> yes
06:01 <iqubic> Because Either is a sum tyoe
06:01 <ertes> although i would have phrased it very differently
06:01 sgronblo joined
06:01 <iqubic> how would you have phrased it?
06:02 <iqubic> now, what do I do with a^2 + 2ab + b^2
06:02 wroathe joined
06:02 ogrady joined
06:02 <jle`> i believe in you
06:02 <iqubic> Also, I know the binomial expasion laws, so the original equation must be true.
06:03 <iqubic> It comes back to Pascal's triangle there.
06:03 <ertes> conjecture: (Bool -> Either A B) is isomorphic to Either (Bool -> A) (Either (Either (A, B) (A, B)) (Bool -> B))
06:03 <jle`> mhm. it's definitely true
06:03 <iqubic> Now I need to put it in types
06:03 <ertes> is that true, and if yes, does it look like something familiar?
06:03 <jle`> iqubic: once you get the types, the interesting part is writing the isomorphism
06:03 <iqubic> I don't have the types yet.
06:03 <ertes> gives the exercise a bit of a mystery touch =)
06:03 m1911 joined
06:03 <jle`> the function from (Bool -> Either a b) -> (whatever the second thing is)
06:04 hurkan joined
06:04 <jle`> and the function from (whatever the second thing is) -> (Bool -> Either a b)
06:04 <iqubic> jle` I know what an isomorphism is.
06:05 SpinTensor joined
06:05 eatman joined
06:05 m1911 joined
06:05 raichoo joined
06:05 <iqubic> Alright time to turn a^2 + 2ab + b^2 into a type.
06:06 <ertes> it's already a type
06:06 <iqubic> yeah, but I need the haskell type signature.
06:06 <iqubic> a^2 is Bool -> a
06:06 sgronblo joined
06:06 <iqubic> b^2 is Bool -> b
06:07 <iqubic> What the heck is 2ab?
06:07 <ertes> iqubic: what's 2?
06:07 <jle`> maybe try looking at it as 2*a*b
06:07 forgottenone joined
06:07 <jle`> and recognizing that you've seen * somewhere before :o
06:07 <iqubic> Oh, I'm stupid
06:07 <jle`> definitely not stupid :)
06:07 <iqubic> (2, (a, b))
06:08 <iqubic> 2ab is this ^^^
06:08 <MarcelineVQ> oh neat, I see it now
06:08 <ertes> or (a, b) + (a, b), if you want =)
06:08 <iqubic> sure.
06:08 <jle`> or (Bool, a, b)
06:09 <iqubic> ertes, that makes 2ab = Either (a, b) (a, b)
06:09 <ertes> iqubic: not equal to
06:09 <iqubic> but an isomorphism
06:09 <jle`> the fact that (Bool, a, b) is isomorphic to Either (a, b) (a, b) is itself an interesting thing :)
06:10 <iqubic> Yeah. It is.
06:10 <jle`> @djinn (Bool, a, b) -> Either (a, b) (a, b)
06:10 <lambdabot> f (a, b, c) =
06:10 <lambdabot> case a of
06:10 <lambdabot> False -> Left (b, c)
06:10 <lambdabot> True -> Right (b, c)
06:10 mohsen_1 joined
06:10 <jle`> @djinn Either (a, b) (a, b) -> (Bool, a, b)
06:10 <lambdabot> f a =
06:10 <lambdabot> case a of
06:10 <lambdabot> Left (b, c) -> (False, b, c)
06:10 <lambdabot> Right (d, e) -> (False, d, e)
06:11 <jle`> aw, so close
06:11 <jle`> would have been really cool if djinn had got the second one right
06:11 <jle`> but i suppose that's not super fair to ask
06:11 <jle`> i'm actually surprised it got something reasonable for the first one
06:12 <iqubic> So a^2 + 2ab + b^2 ~ Either (Bool -> a) (Either (Bool, a, b) (Bool -> b)
06:12 <iqubic> )
06:12 <ertes> iqubic: here is an interesting exercise: find a type x such that: Maybe (Bool, Maybe (Either Ordering Ordering)) ≃ (Ordering, x)
06:12 <jle`> mhm. it might be nice to write Either in infix
06:12 <jle`> s/nice/neat i guess
06:12 <jle`> (Bool -> a) `Either` (Bool, a, b) `Either` (Bool -> b)
06:12 <iqubic> Sure.
06:12 forgottenone joined
06:13 <jle`> to make it a bit more visually similar
06:13 ragepandemic joined
06:13 <jle`> but yeah, now just to write the isomorphisms
06:13 <jle`> i wonder if djinn gets this right
06:13 <jle`> close your eyes if you want to figure this out on your own :)
06:14 <jle`> @djinn ((a, b) -> Bool) -> ((Bool -> a) `Either` (Bool, a, b) `Either` (Bool -> b))
06:14 <lambdabot> Cannot parse command
06:14 <jle`> aw
06:14 <iqubic> Now I need to prove that Bool -> (a, b) ~ (Bool -> a) `Either` (Bool, a, b) `Either` (Bool -> b)
06:14 <jle`> @djinn ((a, b) -> Bool) -> (Either (Bool -> a) (Either (Bool, a, b) (Bool -> b)))
06:14 <lambdabot> -- f cannot be realized.
06:15 <iqubic> Where is it getting f from?
06:15 <jle`> it's calling whatever i wrote f, i guess
06:15 <iqubic> So, the isomorphisms.
06:15 <jle`> the proof is simpler to do in algebra form, (a + b)^2 = (a + b)(a + b) = a^2 + ab + ba + b^2 = a^2 + 2ab + b^2
06:15 <iqubic> I don't see how *I* can do it.
06:15 <jle`> but the interesting thing is writing the function
06:15 <jle`> the two functions
06:15 <iqubic> It is a complex function?
06:15 <ertes> the isomorphisms are tedious, but possible
06:16 <iqubic> I don't like writing tedious and hard code.
06:16 dm3 joined
06:16 <jle`> for me it's kind of simple if you reason about it in english
06:16 <ertes> you pretty much need to enumerate all the individual cases
06:16 jer1 joined
06:16 <jle`> if i have (a + b)*(a + b), what do i really have?
06:17 <jle`> i either have (1) two a's
06:17 <jle`> (2) an a and a b
06:17 <jle`> (3) a b and an a
06:17 edsko joined
06:17 <jle`> (4) two b's
06:17 <iqubic> Right.
06:17 <jle`> so that's exactly what a^2 + ab + ba + b^2 means
06:17 <iqubic> Let me look at the type signatures, and try to get something that works
06:17 <jle`> or, what a^2 + 2ab + b^2 means
06:18 wroathe joined
06:18 <jle`> you either have (1) two a's, (2) an a and a b, in two different orderings, or (3) two b's
06:18 <jle`> but yes the isomorphism is admittedly a bit tedious so feel free to skip it if you understood what i just wrote
06:18 <ertes> also you need to make sure that the two halves of the isomorphism are actually inverses of each other, which is easy to get wrong
06:19 Bashmetim joined
06:19 <iqubic> Right for any isomorphism from (to a) = id
06:19 <iqubic> and to (from a) = id
06:19 <ertes> interestingly, if you use curry-howard to express what isomorphism means, and then use that to construct the semiring, you will construct those isomorphisms as a side effect of proving that types are isomorphic
06:19 ExcelTronic joined
06:19 <ertes> the virtues of constructive mathematics
06:19 <iqubic> What is curry-howard?
06:20 <jle`> another way of looking at +/* and Either/(,), fun stuff
06:20 <iqubic> https://hackage.haskell.org/package/semiring-simple-
06:20 <iqubic> That's a cool package
06:20 Rodya_ joined
06:21 <iqubic> It expands the monoid to include multiplication like operations.
06:21 <ertes> iqubic: type theory is a logical calculus constructed in such a way that types are propositions and terms are proofs of those propositions… this is called the curry-howard correspondence
06:21 <iqubic> Right, I see.
06:21 kritzcreek joined
06:21 <ertes> iqubic: if haskell were a bit stricter, then the function 'id' would be a formal proof that for all propositions 'a', from 'a' follows 'a'
06:22 splanch joined
06:22 <iqubic> ertes: Have *you* written the isomorphism we are disscussing?
06:22 <ertes> in other words: forall a. a -> a
06:22 danthemyth joined
06:22 <ertes> iqubic: no
06:22 <iqubic> Why not?
06:22 <ertes> because i'm satisfied with the fact that it exists… i don't need to actually see it =)
06:23 <iqubic> I also know that it exists.
06:23 <iqubic> I don't really want to take the time to write it out.
06:23 <iqubic> Sounds hard.
06:23 <ertes> iqubic: then try to solve the last exercise i gave you
06:23 <iqubic> Which was...?
06:23 <ertes> iqubic: here is an interesting exercise: find a type x such that: Maybe (Bool, Maybe (Either Ordering Ordering)) ≃ (Ordering, x)
06:24 <iqubic> Is there such a type in Haskell?
06:24 <ertes> data Ordering = LT | EQ | GT
06:24 <ertes> > compare 3 5
06:24 <lambdabot> LT
06:24 <ertes> > compare 5 3
06:24 <lambdabot> GT
06:24 <ertes> > compare 4 4
06:24 <iqubic> That's a sum type.
06:24 <lambdabot> EQ
06:24 <ertes> yeah
06:24 <iqubic> Ordering is a sum type
06:24 biglambda joined
06:24 <iqubic> Is that important to the solution?
06:25 <ertes> it's a matter of how you think about it
06:25 <ertes> Ordering ≃ Maybe Bool
06:25 <iqubic> Why is that?
06:25 <lpaste> jle` pasted “pascal's isomorphism” at http://lpaste.net/354939
06:26 <jle`> you can think of Bool as 2 and Ordering as 3
06:26 <jle`> and () as 1
06:26 <jle`> oh yeah i wrote out the isomorphism because i was bored
06:26 dunx joined
06:26 <ertes> i wish iqubic would have figured that out by themselves…
06:26 <jle`> s/the isomorphism/an isomorphism
06:26 <jle`> ertes: ah, sorry
06:26 <iqubic> It's cool. I was not going to write that myself ever.
06:27 sproingie joined
06:27 <jle`> that's what i would have said if someone told me two years ago
06:27 <jle`> but look where i am now
06:27 <ertes> iqubic: well, Maybe, as a type function, is much like (1 +)
06:27 <iqubic> Sure.
06:27 <iqubic> I get that.
06:27 <iqubic> Oh and Bool = 2
06:27 <iqubic> Sorry is isomorpic to 2
06:28 <ertes> yeah, or alternatively: Either ()
06:28 <ertes> where () ≃ 1
06:28 <cocreature> iqubic: now try to figure out Either and (,) :)
06:28 <iqubic> Sure.
06:28 <ertes> iqubic: now rewrite the equivalence
06:28 dm3 joined
06:28 <ertes> i.e. apply what you have learned to this: Maybe (Bool, Maybe (Either Ordering Ordering)) ≃ (Ordering, x)
06:29 <ertes> hint: you can reduce the whole left side to something *very* small
06:29 <iqubic> Maybe (Bool, Maybe (Either Ordering Ordering) ~ 1 + (2 * (1 + (3 + 3))
06:29 <rotaerk> hmm... wonder how I'm supposed to catch the "invalid argument" exception if InvalidArgument isn't exposed from System.IO.Error...
06:29 <ertes> iqubic: yeah
06:30 <ertes> iqubic: feel free to give that type a name: 15
06:30 <iqubic> Ah, That just 2 bytes.
06:30 salva joined
06:30 <ertes> characters =)
06:30 <rotaerk> seems like a weird error to catch, but in this case it's being thrown by TCP.recv
06:30 <rotaerk> when the socket's closed before or while it runs
06:30 <ertes> iqubic: now rewrite the right side to something nicer
06:31 <iqubic> ertes: Or Word16 works too.
06:31 <rotaerk> hmm guess I'll filter on message instead of type
06:31 <iqubic> No, actually that's too large
06:31 <iqubic> ertes: How can I rewrite the Right side?
06:31 <ertes> iqubic: Ordering ≃ 3
06:31 <ertes> (Ordering, x) ≃ ?
06:31 <iqubic> So...?
06:32 <iqubic> Ah. x ~ 5
06:32 <ertes> there you go =)
06:32 <iqubic> But what Haskell type has 5 values?
06:32 takuan joined
06:32 <ertes> Maybe (Either Bool Bool)
06:32 <iqubic> Alright then. That works
06:33 <jle`> rotaerk: you can check the show, heh
06:33 <ertes> note: try not to reason in terms of size, because that will be a problem with infinite types
06:33 <cocreature> rotaerk: you can get it from GHC.IO.Exception
06:33 <rotaerk> ahh
06:33 <ertes> we don't have cardinal numbers in type theory… at least not in the way they work in set theory
06:33 zeroed joined
06:33 zeroed joined
06:33 wroathe joined
06:35 alexbiehl joined
06:35 <iqubic> Now write this in mathematical symbols. Bool -> a ~ (a, a) -> Bool
06:35 <iqubic> I think that's an isomorphism I remember seeing. Not sure if it actually works.
06:35 <cocreature> that’s not an isomorphism
06:36 <iqubic> It isn't?
06:36 <iqubic> I thought it was.
06:36 <iqubic> Yeah, your right it isn't
06:36 <cocreature> the first is a^2 while the second is 2^(a^2)
06:36 <jle`> iqubic: you're trying to say that a^2 is the same as 2^(a*a)
06:36 <rotaerk> worked
06:36 <ertes> iqubic: refutation: a = 1: 1^2 ≠ 2^1
06:37 govg joined
06:37 <ertes> read "≠" as "/≃" there… i don't have "not isomorphic" on my keyboard =)
06:37 jer1 joined
06:37 detrumi joined
06:38 <iqubic> toPair f = (f True, f False) ~ fromPair (a, b) = if true then a else b
06:38 <iqubic> That's what I was going for.
06:38 <iqubic> Not sure if that actually works though.
06:38 <cocreature> "if true" ?
06:39 <cocreature> what’s true supposed to be
06:39 <iqubic> I don't know.
06:39 <cocreature> well you wrote this, shouldn’t you know? :)
06:39 newhoggy joined
06:39 kau joined
06:39 hamishmack joined
06:40 <iqubic> (Bool -> a) -> (a, a) ~ (a, a) -> (Bool -> a)
06:40 <iqubic> That's the isomorphism I was looking for.
06:40 <iqubic> toPair f = (f True, f False) ~ fromPair (a, b) c = if c then a else b
06:41 <iqubic> That's the isomorphism as two functions.
06:41 <iqubic> Now, I want to know the algebra of that isomorphism
06:42 <ertes> iqubic: that's an actual isomorphism
06:42 <iqubic> I know.
06:42 <iqubic> Now I want to put it into symbols.
06:42 <ertes> but note that it proves that *conversion functions* are isomorphic
06:42 <iqubic> I know.
06:42 <iqubic> I like it a lot
06:43 <ertes> (a*a)^(a^2) ≃ (a^2)^(a*a)
06:43 <ertes> for all a
06:43 <iqubic> And I ca clearly see how that works.
06:43 <iqubic> s/ca/can
06:44 razi1 joined
06:45 lambda-11235 joined
06:46 v0latil3_ joined
06:47 <iqubic> How many isomorphisms exist?
06:47 <cocreature> you first need to define when two isomorphism are different before you can answer that question
06:48 <iqubic> LOL
06:48 <cocreature> I’m not joking. it’s not clear what the right notion of equality on functions is
06:48 <rotaerk> hmm annoying. ioeGetErrorString is implemented to return the error *type* if the IOError is anything but a UserError
06:48 <ertes> iqubic: it's not a joke
06:48 filostrato joined
06:48 <rotaerk> so I can't get the "Bad file descriptor" string from the exception
06:49 <ertes> iqubic: you are now entering the realm of infinity-groupoids and homotopy type theory =)
06:49 <cocreature> rotaerk: GHC.IO.Exception exposes the constructor of IOException so you should be able to just pattern match
06:49 wroathe joined
06:49 <rotaerk> ah, cool
06:49 oish joined
06:50 <cocreature> rotaerk: but I feel your pain. working with IOException is really weird
06:50 <iqubic> I don't know anything about haskell exceptions.
06:50 <iqubic> I avoid them like the plague.
06:50 <ertes> iqubic: your seemingly innocent question is a subject of active research by very smart people
06:50 <MarcelineVQ> it really is, a lot of the time the useful info is locked behind ioe_description as plain text
06:50 <rotaerk> yep, that worked
06:51 <ertes> IO exceptions are actually quite nice, once you understand how they work and interact in concurrent programs
06:51 mjora7 joined
06:51 dylukes joined
06:51 <cocreature> ertes: I’m not talking about IO exceptions, I’m talking about the IOException type
06:52 <MarcelineVQ> ResourceExhausted for example has many causes and your only lead is what ioe_description might or might not report
06:52 laplacian joined
06:52 <ertes> cocreature: i was answering to iqubic
06:52 <cocreature> ah sry
06:53 <ertes> and yes, IOException is perhaps my least favourite type in the base library
06:53 <MarcelineVQ> I wonder if there's an exceptions lib around that has better categorisation for those vaguer errors
06:53 Bashmetim joined
06:53 acidjnk22 joined
06:53 <ertes> MarcelineVQ: it wouldn't help, because base still throws the regular ones
06:53 seveg joined
06:54 <ertes> MarcelineVQ: i have such a library, which is supposed to make error responses easier to program, but it's awkward to work with
06:54 <MarcelineVQ> well what I mean is something to interpered the base version into something richer, for example for ResourceExhausted it could do the work of deciding if ioe_description is talking about file handles or disk space etc
06:54 <cocreature> lens at least makes the interface slightly better than these weird boolean functions for checking which kind of IOException was thrown
06:55 filostrato joined
06:57 jer1 joined
07:00 filostrato joined
07:00 refold joined
07:03 filostrato joined
07:03 raichoo joined
07:03 guiben joined
07:03 baldrick joined
07:04 ubsan_ joined
07:04 butterthebuddha joined
07:05 wroathe joined
07:07 mmn80 joined
07:07 augur joined
07:08 soniku joined
07:09 nickager joined
07:09 fizruk joined
07:12 dev-Zero joined
07:13 nickolay joined
07:14 fendor joined
07:14 oish joined
07:15 Itkovian joined
07:16 blender3 joined
07:17 kvda joined
07:17 binaryplease joined
07:19 coot___ joined
07:21 laz joined
07:21 Rodya_ joined
07:21 wroathe joined
07:21 jer1 joined
07:22 takle joined
07:22 raichoo joined
07:23 mattyw joined
07:25 <fendor> i love it that it is so empty in the morning
07:26 <cocreature> only 1488 people, it’s really empty :)
07:28 thc202 joined
07:28 splanch joined
07:28 bertschneider joined
07:28 albertid joined
07:28 aloiscochard joined
07:29 sgronblo joined
07:29 yoneda joined
07:29 richi235 joined
07:30 bvad joined
07:32 rockfordal joined
07:32 sword865 joined
07:36 blender3 joined
07:36 dylukes joined
07:36 biglama joined
07:37 wroathe joined
07:37 connrs joined
07:37 dylukes joined
07:38 dylukes joined
07:38 dylukes joined
07:39 osa1 joined
07:39 eklavya joined
07:39 reuben364 joined
07:41 jer1 joined
07:41 butterthebuddha joined
07:41 augur joined
07:41 plot joined
07:41 biglama joined
07:42 alfredo joined
07:42 takle joined
07:43 <reuben364> Yo. Can anybody tell me why this won't typecheck and how to fix it: https://pastebin.com/z3XL306L
07:44 <opqdonut> you might need ScopedTypeVariables
07:44 <opqdonut> otherwise you can't refer to the same w
07:44 ventonegro joined
07:44 <reuben364> That is already included.
07:45 <opqdonut> ok
07:45 <opqdonut> what's the error?
07:45 sgronblo joined
07:45 <reuben364> It can't find the instance of FiniteBits
07:46 <reuben364> I think for some reason the ScopedTypeVariables isn't carying the constraint.
07:46 gmcabrita joined
07:47 <opqdonut> btw the nicer way to type this is
07:47 <reuben364> But I wouldn't know how to fix that.
07:47 <opqdonut> example proxy = finiteBitSize (undefined `asProxyTypeOf` proxy)
07:50 <reuben364> K, that fixes the example, but the context that I wanted to use such a function still doesn't work.
07:50 <opqdonut> weird
07:51 <reuben364> I want to write a function beSplit :: (Integral w, FiniteBits w, Integral v, FiniteBits v) -> v -> [w]
07:51 mathk joined
07:51 balor joined
07:51 <mathk> @pl (\ch -> 'a'<=ch && ch <= 'z')
07:51 <lambdabot> liftM2 (&&) ('a' <=) (<= 'z')
07:52 mstruebing joined
07:52 shayan_ joined
07:52 <reuben364> k, brb. need to leave with laptop and don't have bnc
07:53 wroathe joined
07:53 <opqdonut> reuben364: try an explicit forall, it fixes your `example` function for me. So: example :: forall w. FiniteBits w => Proxy w -> Int
07:53 <mathk> @pl (\ch a z -> a <=ch && ch <= z)
07:53 <lambdabot> ap (flip . (((.) . (&&)) .) . flip (<=)) (<=)
07:54 ogrady_ joined
07:54 raichoo joined
07:54 fizruk joined
07:54 ogrady_ joined
07:56 ogrady__ joined
08:00 reuben364 joined
08:00 <dysfun> is there some writeup on type families that explains it like it's an idiot reading?
08:00 coot___ joined
08:02 <phz_> hey
08:03 <phz_> :t (#)
08:03 <lambdabot> error: parse error on input ‘)’
08:03 <phz_> anyone knows where this operator come from?
08:03 <phz_> (besides lens, of course)
08:03 <phz_> I saw it in diagrams samples code
08:04 blender3 joined
08:04 blym_ joined
08:05 coot___ joined
08:05 <reuben364> continuing the discussion on my problem: https://pastebin.com/z3XL306L
08:06 jer1 joined
08:06 <[exa]> dysfun: it's for adhoc overloading; i.e. when all overloaded stuff with one name doesn't actually have the same type scheme
08:07 sproingie joined
08:07 <[exa]> dysfun: C++ and template specializations (e.g. vector<bool> a completelly different structure than vector<int>) are a prime example of adhoc overloading
08:08 <dysfun> aha, i know c++ templates
08:09 <dysfun> i'm building something like datascript in haskell and i have some difficulties tightening up some of the looseness you get in datascript (because clojure is a dynamic language)
08:09 <dysfun> i am not quite sure if type families are the answer
08:10 soniku joined
08:10 <dysfun> my gut feeling with comparison to c++ templates is no
08:10 simukis_ joined
08:10 <[exa]> dysfun: now to do that, you need some logic in type system that for type (Vector Bool) generates one specialization (i.e. one form of data constructor) and for type (Vector _whatever) generates a generic one
08:11 <dysfun> oh right
08:11 <dysfun> i see
08:11 <dysfun> thanks ;)
08:11 <[exa]> the fact that it is carried out by "type functions" and that Vector is now a type function can be abstracted out I guess
08:11 <[exa]> maybe dive directly into your problem?
08:11 <dysfun> good idea
08:12 <dysfun> datascript essentially stores all data as (entity,attribute,value) tuples, so it's pretty loose
08:12 gfixler joined
08:12 <dysfun> they have a schema where you can add validation on top
08:13 <dysfun> the closest haskell equivalent to that seem to be to define a datatype that is a union of all possible attributes
08:13 <dysfun> am i making sense so far?
08:14 <[exa]> so you want to rewrite the schemas to type language and expect not to receive an invalid schema, right?
08:14 <[exa]> *invalid tuples
08:14 mjora7 joined
08:14 blender3 joined
08:15 freusque joined
08:16 <dysfun> well, this is all quite experimental, but at the minute i've defined a datatype that is a union of all possible attributes. For example in datascript you may have an (1,UserEmail,123) ; pseudocode
08:16 <dysfun> i've dropped the tuple part and gone for a datatype where UserEmail String is one of the constructors
08:16 <dysfun> that 123 should have been "foo@example.org" of course
08:18 <dysfun> now, i figure i can create an enum instance to derive an 'attribute' value (because they're just unique identifiers) and the value can be that union type
08:18 aib joined
08:20 <dysfun> but now i am trying to do the rest of their schema. for example they have three possible uniquenesses - not unique, unique where insert duplicate is an error, unique where duplicates overwrite
08:21 <[exa]> well, not sure if the type system can handle uniqueness
08:21 <dysfun> i don't expect it to - i'll check :)
08:21 tomku joined
08:21 DocWinter joined
08:21 <[exa]> you'd have to stuff in some kind of function that stores other values and autochecks it
08:22 <dysfun> but now i'm writing a typeclass method for each of the possible values (with the idea being that you can choose for each of the constructors of the datatype what Uniquity to return, Cardinality to return etc. and the default is Nothing
08:22 Rodya_ joined
08:22 DocWinter joined
08:23 <[exa]> so I guess you want the function "specialized" for different cases of uniquity (unique returns Maybe a, non-unique returns [a], exact cardinality can return (a,a,a...) ) etc?
08:24 coot____ joined
08:24 lep-delete joined
08:24 danthemyth joined
08:24 wroathe joined
08:25 jer1 joined
08:25 <dysfun> hrm, i hadn't considered that. datascript just has 'one' and 'many'
08:25 splanch joined
08:25 <[exa]> if that's true it sounds a tiny bit like multiparameter typeclasses
08:25 <[exa]> https://downloads.haskell.org/~ghc/4.08/docs/set/multi-param-type-classes.html
08:25 <phz_> hm, is there a function that takes a list and remove its duplicate using a Set?
08:25 <phz_> toList . fromList, something like that
08:25 <dysfun> already using multiparameter typeclasses :)
08:25 alfredo joined
08:26 <reuben364> I have no background of datascript. Is the collection of tuples (e, a, v) a superset of databases, where each entry can have any number of attributes.
08:26 <[exa]> phz_: nub
08:26 <dysfun> nub removes duplicates
08:26 <phz_> [exa]: it’s implemented with a Set?
08:26 <[exa]> phz_: probably not, docs say it's O(n^2)
08:26 <phz_> O(n^2)
08:26 <phz_> yep
08:26 <phz_> I don’t want that then
08:27 <dysfun> reuben364: e is an integer, a is one of a set of keywords (which can be added to by simply using a column) and v is any value at all
08:27 splanch_ joined
08:27 <[exa]> The name nub means `essence'. wat.
08:27 <dysfun> so it's (entity-id, attribute-id, attribute-value)
08:27 <phz_> [exa]: don’t look for the meaning
08:27 <phz_> :D
08:27 ogrady joined
08:28 <phz_> Haskell gets exotic in a lot of spaces
08:28 <dysfun> [exa]: anglicism
08:28 <[exa]> it always amazes me.
08:28 <phz_> it’s all about pictures!
08:28 xtreak joined
08:28 <phz_> the fix function, even though it means something, has an exotic name to me
08:28 <phz_> fix is more about recursion than finding a fix point :)
08:29 <[exa]> you said it, "is more about recursion than finding a fix point" is exactly the basic property of Y
08:29 <[exa]> naming is hard.
08:30 <phz_> [exa]: of Y?
08:30 <dysfun> reuben364: there are then three indexes of these tuples, which are collections ordered by three different permutations of column order
08:30 MindlessDrone joined
08:31 <mniip> phz_, it does find the least fix point
08:31 Argue joined
08:31 <phz_> mniip: we don’t use it for that
08:31 <mniip> the least fixpoint of '1:' is 'cycle 1'
08:31 <phz_> we use it to bind a recursive value inside itself
08:32 <phz_> yeah
08:32 <mniip> phz_, that's the same thing
08:32 <phz_> mniip: well to me those are two different things
08:32 <[exa]> phz_: the other name for fix.
08:32 <dysfun> reuben364: a user is able to write a query using a datalog dialect that queries it
08:33 <dysfun> i'll worry about the query engine later, that's obviously going to be difficult
08:33 <mjora7> The Haskell text that I'm using uses (x:xs) for array parameter pattern matching. What does the 'x' and 'xs' stand for, something mathematical? I'd call them 'head' and 'tail', or something like that.
08:33 butterthebuddha joined
08:33 <dysfun> if x = 'ex', than 'xs' = 'exes'
08:34 <mjora7> dysfun: Hahh, ok, that makes sense.
08:34 tomphp joined
08:34 <mniip> (x:xs), you have one x, and multiple x'es
08:34 cschneid_ joined
08:35 <mjora7> Is this a common name scheme that people use, or just my textbook?
08:35 <dysfun> it's pretty widely used
08:35 <mniip> yes
08:35 dandrona joined
08:35 sgronblo joined
08:35 <dysfun> in prolog and erlang they use h and t a lot
08:35 kamyar joined
08:36 msks joined
08:36 <mjora7> dysfun: Thanks.
08:36 <dysfun> remember that 'head' and 'tail' exist in prelude
08:36 <kamyar> hello all
08:36 <kamyar> Any Haskell pro here?
08:36 <dysfun> yes
08:37 <kamyar> Is this article applicable? http://nikita-volkov.github.io/record/
08:37 <mjora7> dysfun: Yep.
08:37 yinn joined
08:38 <dysfun> there are several first class records libraries. what do you mean applicable?
08:38 <mivael> hello all!
08:39 <kamyar> dysfun: I mean if it is mature and valid, why it is not viral and popular?
08:39 <mivael> I wonder whether using a Builder is necessary to convert an integer value to ByteString? Or maybe I'm missing something?
08:39 vi0 left
08:40 jgertm joined
08:40 wroathe joined
08:40 mthek joined
08:40 Qfwfq joined
08:40 <cocreature> kamyar: because a lot of people don’t like TH
08:40 <dysfun> i'm immediately put off by the fact it uses two quasiquoters
08:41 eliasr joined
08:42 <kamyar> cocreature: Many projects like Persistent and other ORM-like libraries use TH but do not use any first class record
08:42 fakenerd_ joined
08:43 wahrsagevogel joined
08:43 <dysfun> but there are first class record libraries that don't use TH
08:43 v0latil3_ left
08:44 v0latil3 joined
08:45 SlashLife joined
08:45 Swizec joined
08:46 keemyb joined
08:46 jer1 joined
08:47 <ertes> mivael: Builder is never *necessary*, but if you need to build a ByteString from a concatenation of multiple chunks, Builder is going to be significantly more efficient than appending ByteString
08:49 soLucien joined
08:49 coot____ joined
08:49 <ertes> mivael: instead of storing the actual string, it stores instructions on how to build the string… when building a lazy ByteString from a Builder chunks of fixed lengths are allocated and filled from the Builder
08:50 gehmehgeh joined
08:50 <mivael> thanks, now it makes sense for me
08:51 blym joined
08:52 danza joined
08:53 zero_byte joined
08:54 Xanather joined
08:54 Yuras joined
08:54 <mjora7> Trying to implement filter two different ways, why does the second one fail? As far as I know, I'm doing the exact some thing, one with parameter pattern matching, and one with guards: https://repl.it/H1XK/0
08:55 <mjora7> Ahhh... I think I see what is wrong. The list@(x:xs) isn't a catch all pattern.
08:55 <mjora7> That makes sense. Is there a way to make it one but still capture (x:xs)?
08:55 <mjora7> I guess I could use head and tail on it.
08:56 nickager joined
08:56 wroathe joined
08:56 bjz joined
08:56 <mivael> Is there any way to abstract from specific integer type when using ByteString.Builder? I mean something like 'decimal' (Data.Text.Lazy.Builder.Int) instead of int32Dec, int64Dec, ...?
08:57 <mjora7> Revised edition, I think that's the proper way: https://repl.it/H1XK/1
08:58 <mjora7> Pattern matching is much nicer :)
08:58 <mniip> mjora7, filter2 is bad style
08:58 <mniip> make sure to avoid that kind of cod
08:58 <mniip> e
08:58 <mjora7> mniip: Ok, I agree, but can you explain why it is bad style? From what I see, it's just not as readable.
08:59 <mniip> head and tail are partial
08:59 puregreen joined
08:59 <mniip> in fact here you are relying in lazy evaluation
08:59 <mniip> with partial functions is much harder to reason about totality of your function
08:59 <mjora7> mniip: Partial?
08:59 <mniip> it doesn't return a value on all inputs
09:00 <mjora7> mniip: Ah, like an empty list.
09:00 <mniip> yes
09:01 <mjora7> mniip: Any other tips for good style, at my skill level (you can probably tell what it is from that code/my questions)?
09:01 eacameron joined
09:01 <mniip> fn -> f
09:02 <mniip> if you have 2 or more functions you can go f, g, h
09:02 <mjora7> mniip: Ok
09:02 <mniip> | cond = x; | otherwise = y
09:02 <mniip> is better expressed as 'if cond then x else y'
09:03 <mjora7> mniip: I'm definitely having a hard time with the sparse naming. Is that a Haskell thing?
09:03 <mniip> if there's only 2 branches, why use guards
09:03 <mjora7> mniip: Ah ok yeah I thought about writing it that way
09:03 <mniip> questionable advice though
09:03 Yuras joined
09:03 <mniip> some would disagree
09:03 <mniip> mjora7, can't say much more than that because your definition is identical to the prelude definition
09:03 <mniip> @src filter
09:03 <lambdabot> filter _ [] = []
09:03 <lambdabot> filter p (x:xs)
09:03 <lambdabot> | p x = x : filter p xs
09:03 <lambdabot> | otherwise = filter p xs
09:03 SadoqueTD joined
09:03 rockfordal joined
09:04 <mjora7> if `cond then x else y` reminds me of the ternary operator `cond ? true-branch : false-branch` from C, which I like.
09:04 <mjora7> mniip: That's neat!
09:04 <gehmehgeh> mjora7: It is the ternary operator
09:04 <mjora7> gehmehgeh: Awesome.
09:05 <gehmehgeh> mjora7: (As far as I know)
09:05 <mjora7> gehmehgeh: Looks a little nicer though.
09:06 jer1 joined
09:06 jeltsch joined
09:07 sproingie joined
09:07 marr joined
09:07 <mjora7> mniip: Is this the proper way to format that? I think it's a bit hard on the eyes as a one liner. https://repl.it/H1XK/3
09:08 <mniip> there's no proper way
09:08 <mniip> also I'm not the best person to ask because I have a fairly peculiar formatting preference
09:08 <mniip> (I use tabs too)
09:08 <reuben364> dysfun: perhaps some inspiration with using type families https://pastebin.com/D0c9G3uU
09:09 <mjora7> mniip: That's scary.
09:09 <dysfun> reuben364: thanks :)
09:11 mthek joined
09:11 Pilfers joined
09:11 <mniip> edwardk, you around?
09:11 <reuben364> dysfun: It may be terrible. I don't know a lot about haskell's extensions, but I am a bit familiar with dependently typed programming.
09:11 <dysfun> i've done a little bit with agda
09:12 wroathe joined
09:12 WizJin joined
09:12 aib joined
09:13 xtreak joined
09:15 oish joined
09:16 uiop joined
09:16 CurryWurst joined
09:17 dm3 joined
09:19 forgottenone joined
09:19 sampuka joined
09:19 sirreal joined
09:20 <reuben364> Say I have a function example :: (Integral v, FiniteBits v) => Whatever -> [v], is it possible to use finiteBitSize for the v type. I have tried with ScopedTypeVariables and it doesn't work.
09:20 <mniip> it's possible without scopedtyvars
09:20 <mniip> but it's tricky
09:20 oish_ joined
09:21 Frans-Willem joined
09:21 fizbin joined
09:22 <mniip> @let example = let result = replicate (finiteBitSize (head result)) 0 in result
09:22 <lambdabot> Defined.
09:22 <mniip> :t example
09:22 <lambdabot> (Num b, FiniteBits b) => [b]
09:22 <mniip> > example :: [Int]
09:22 <lambdabot> [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0...
09:22 <mniip> > example :: [Word8]
09:22 xtreak joined
09:22 <lambdabot> [0,0,0,0,0,0,0,0]
09:22 OnkelTem joined
09:22 <reuben364> XD
09:22 <mniip> do note that 'head' is here just for the type inference, it is never invoked
09:23 Rodya_ joined
09:23 <mniip> with scopedtyvars
09:23 xtreak joined
09:23 <mniip> @let example' :: forall v. (Num v, FiniteBits v) => [v]; example' = replicate (finiteBitSize (undefined :: v)) 0
09:23 <lambdabot> Defined.
09:24 <mniip> :t example'
09:24 <lambdabot> (FiniteBits v, Num v) => [v]
09:24 <mniip> > example' [Word8]
09:24 <lambdabot> error:
09:24 <lambdabot> • Couldn't match expected type ‘[t0] -> t’ with actual type ‘[v0]’
09:24 <lambdabot> • The function ‘example'’ is applied to one argument,
09:24 <mniip> > example' :: [Word8]
09:24 <lambdabot> [0,0,0,0,0,0,0,0]
09:24 <mniip> you need explicit foralls for the vars you want to be scoped
09:25 <reuben364> Well there's my problem.
09:25 <reuben364> Thanks.
09:25 sirreal joined
09:26 <filostrato> I'm trying to set up for Yesod development atm, but running into something I'm not sure is specific to Yesod: `Failed to load interface for ‘Yesod’`
09:26 <filostrato> thought I had set things up correctly
09:27 jer1 joined
09:34 alanb99 joined
09:34 coot____ joined
09:35 ersran9 joined
09:35 ersran9 joined
09:37 thunderrd joined
09:40 blym_ joined
09:42 heurist joined
09:43 alanb99 left
09:47 msks joined
09:48 danza joined
09:51 jer1 joined
09:52 AndroUser joined
09:58 flatmap13 joined
09:59 wroathe joined
09:59 tomphp joined
10:00 petermw joined
10:01 reuben364 joined
10:02 <mivael> Could anyone help with attoparsec?
10:02 <mniip> with what specifically
10:02 <mivael> GHC says that (parseOnly myparser) has type (Data.ByteString.Internal.ByteString -> Either P.String [a0]) although it should be (Data.ByteString -> Either String a) according to the docs (http://hackage.haskell.org/package/attoparsec-
10:03 alqatari joined
10:03 beerdrop joined
10:03 <mniip> what's the type of 'myparser'?
10:05 <mivael> I did not try to specify its type explicitly.
10:05 <mivael> (A8.decimal `A8.sepBy1` (A8.char ' ')) <* A8.endOfInput -- Data.Attoparsec.ByteString.Char8 as A8
10:05 <mniip> what type does ghc infer for it
10:05 f1b3r joined
10:05 fbergmann joined
10:05 flatmap13 joined
10:05 <mivael> I will check.
10:07 doomlord joined
10:08 chao-tic joined
10:09 petermw joined
10:09 blym_ joined
10:09 butterthebuddha joined
10:10 jer1 joined
10:11 soniku joined
10:12 <mivael> mniip, I thought I can do it :) I have very little experience wiith ghci, do not know how to check that.
10:12 locallycompact joined
10:12 <mniip> :t myparser
10:13 <mivael> *Main> myparser = (A8.decimal `A8.sepBy1` (A8.char ' ')) <* A8.endOfInput
10:13 <mivael> <interactive>:3:10: parse error on input ‘=’
10:14 <mniip> add a 'let'
10:14 <mivael> oh
10:14 javjarfer joined
10:14 Kototama joined
10:14 <mivael> myparser
10:14 <mivael> :: P.Integral a =>
10:14 <mivael> Data.Attoparsec.Internal.Types.Parser
10:14 <mivael> Data.ByteString.Internal.ByteString [a]
10:14 <mniip> well
10:14 <mniip> sounds about right then
10:15 <mniip> that it returns Either String [a]
10:15 <mivael> That's okay.
10:15 <mniip> I don't see what your problem is then
10:15 <Kototama> how can Traversable be implemented (without deriving) for a type data Exp a = Num Int | Mul (List a) ?
10:16 <mivael> mniip, The problem that it can not match Data.ByteString.Internal.ByteString with Data.ByteString
10:16 <mniip> List a?
10:16 <mniip> mivael, Data.Bytestring is not a type
10:16 <Kototama> [a] ?
10:16 <mivael> mniip, sorry I was not specific
10:16 <Kototama> how to get a value of type `a` when traversing the (Num Int) node?
10:17 <mniip> traverse f (Num x) = pure (Num x)
10:17 <mniip> traverse f (Mul xs) = Mul <$> traverse f xs
10:17 <mivael> mniip, Couldn't match type ‘B8.ByteString’ with ‘Data.ByteString.Internal.ByteString’ -- Data.ByteString.Lazy.Char8 as B8
10:18 <mniip> mivael, well, you are mixing strict and lazy bytestrings
10:18 <mniip> is there any reason you need lazy bytestrings
10:18 <mivael> a large number of integers are in my input
10:18 <Kototama> shouldn't traverse return a type m (t b) whereas in pure (Num x) is of type m (t a) ?
10:19 Wizek_ joined
10:19 <mivael> mniip, I want to avoid reading the whole stdin into memory
10:19 uglyfigurine joined
10:20 <mniip> mivael, well, in order to 'parseOnly' you will have to do that
10:20 <mniip> Kototama, yes and yes
10:20 <hexagoxel> Kototama: the (Num x) have different types on both sides of the equation
10:20 <mniip> however notation prevents you from seeing that it isn't a problem
10:20 <mniip> Num x has that type 'forall a'
10:21 <mniip> traverse should return that type with a specific b
10:21 <mivael> I'm not sure I need parseOnly. What other options I have? (Ones which are compatible with lazy bytestrings.)
10:21 <mniip> (b is a skolem type variable)
10:21 splanch joined
10:21 <mniip> aka rigid
10:21 <mniip> mivael, googling attoparsec lazy bytestring seems to yield some results
10:22 <Kototama> oh i see, thank you
10:25 NyanPasu joined
10:25 danthemyth joined
10:26 newhoggy joined
10:28 <mivael> mniip, Data.Attoparsec.ByteString.Lazy, I see. Does this mean that I should use Data.Attoparsec.ByteString.Parser, not Data.Attoparsec.ByteString.Char8.Parser?
10:28 bennofs joined
10:28 <mniip> uhhh
10:28 <mniip> that I'm not sure
10:28 <mniip> Char8 is a bad idea in general
10:28 blym_ joined
10:29 <mivael> Someone advised me to them earlier. Why are they bad in general?
10:29 <EvanR> instead of Char8 you can use local definitions of commonly used "chars", like let lf = w8 10
10:29 tommd joined
10:29 <EvanR> > ord '\n'
10:29 <lambdabot> 10
10:30 balor joined
10:30 wroathe joined
10:30 danza joined
10:32 Argue joined
10:33 kuribas joined
10:33 <mivael> EvanR, well, I'm not sure I understood. I will try to avoid *.Char8, though. What specific purpose do *.Char8 have?
10:33 <EvanR> its supposed to be convenient when you only have ASCII data
10:33 <mniip> it's for lazy people who don't care about encoding
10:33 coot____ joined
10:34 <EvanR> many binary protocols have ASCII text embedded within then in places
10:34 <EvanR> if its all ASCII... then were not talking about binary anymore, nor is it unicode, so we have a missing feature in haskell
10:34 <EvanR> the 7bit ascii char data type
10:35 <EvanR> situation shouldnt be ignore imo
10:35 <EvanR> ignored
10:35 jer1 joined
10:37 splanch joined
10:37 m` joined
10:38 xtreak joined
10:38 <dysfun> reuben364: think this code example is starting to make sense. feels like magic
10:39 <quchen> type SevenBit = Either Bool (Either (Bool,Bool) (Either (Bool, Bool, Bool) (Either …)
10:39 danthemyth joined
10:39 <mniip> quchen, that has one too few inhabitants
10:40 <EvanR> Vect 7 Bit
10:40 xtreak joined
10:40 <mniip> try...
10:40 <mivael> EvanR, mniip: that's competitive programming contests, ascii only
10:40 <mniip> :t let f :: x -> Either x x in f (f (f (f (f (f (f x))))))
10:40 <lambdabot> error:
10:40 <lambdabot> The type signature for ‘f’ lacks an accompanying binding
10:40 <mniip> :t let f :: x -> Either x x; f=f in f (f (f (f (f (f (f x))))))
10:40 <lambdabot> Either (Either (Either (Either (Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (Either Expr Expr) (Either Expr Expr))) (Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (
10:40 <lambdabot> Either Expr Expr) (Either Expr Expr)))) (Either (Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (Either Expr Expr) (Either Expr Expr))) (Either (Either (Either Expr Expr) (Either Expr
10:40 <lambdabot> Expr)) (Either (Either Expr Expr) (Either Expr Expr))))) (Either (Either (Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (Either Expr Expr) (Either Expr Expr))) (Either (Either (
10:40 <lambdabot> Either Expr Expr) (Either Expr Expr)) (Either (Either Expr Expr) (Either Expr Expr)))) (Either (Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (Either Expr Expr) (Either Expr Expr))) (
10:40 <lambdabot> Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (Either Expr Expr) (Either Expr Expr)))))) (Either (Either (Either (Either (Either (Either Expr Expr) (Either Expr Expr)) (Either (
10:40 <lambdabot> [5 @more lines]
10:41 <mniip> oops s/Expr/()/
10:41 heurist joined
10:41 <mivael> EvanR, mniip: Data.Attoparsec.ByteString does not seem to contain 'decimal'... (it is in Char8 subspace for some reason)
10:42 f1b3r joined
10:42 <Myrl-saki> mniip Reeee. What.
10:43 fakenerd joined
10:43 JagaJaga joined
10:43 <biglambda> How would I use attoParsec to read a 32 bit float from a byteString?
10:43 aib joined
10:44 <EvanR> mivael: since decimal gives you a regular Internal.Parser ByteString, should work fine with other stuff
10:44 JuanDaugherty left
10:44 <Myrl-saki> ertes: Yep.
10:44 <EvanR> biglambda: read 4 bytes, then decode float
10:44 <EvanR> :t decodeFloat
10:44 <lambdabot> RealFloat a => a -> (Integer, Int)
10:44 <EvanR> hmm
10:44 yellowj joined
10:45 <Myrl-saki> :t encodeFloat
10:45 <lambdabot> RealFloat a => Integer -> Int -> a
10:45 <Myrl-saki> What does that mean?
10:45 <mniip> exponent, mantissa
10:45 latro`a joined
10:46 <EvanR> yeah, im missing the one that encodes decodes literal ieee754 binary
10:46 <EvanR> > decodeFloat 3.14
10:46 <lambdabot> (7070651414971679,-51)
10:46 <EvanR> > encodeFloat 7070651414971679 (-51)
10:46 <lambdabot> 3.14
10:46 wroathe joined
10:46 <Myrl-saki> > encodeFloat 1 1
10:47 <lambdabot> 2.0
10:47 <Myrl-saki> Interesting...?
10:47 <biglambda> EvanR what module is decodeFloat in?
10:47 <opqdonut> EvanR: Data.Binary sounds right for that
10:47 <Myrl-saki> Prelude
10:47 <EvanR> > sqrt 2 / 2
10:47 <lambdabot> 0.7071067811865476
10:48 <biglambda> opqdonut: I’m basically looking for a combination of Parsec and Data.Binary
10:48 ub joined
10:48 nighty-- joined
10:48 <Myrl-saki> biglambda: Well, yeah. attoparsec is what you need.
10:49 <Myrl-saki> Also.
10:50 <Myrl-saki> You should be able to use {encode,decode}Float here, but it will be a mess.
10:50 <mniip> (unsafeCoerce :: Double -> Int64)
10:50 richi235 joined
10:50 <EvanR> one thing about 32bit encoded floats is theres endianness issues, which you have to decide on when programming it yourself
10:51 <EvanR> but i would expect this to be solved, which i suspect has been done in Data.Binary
10:51 <mniip> but yeah, otherwise you have to take the 8 bytes,
10:51 <mniip> split the sign, exponent, mantissa with bit shifts
10:51 <mniip> and then encodefloat
10:51 <Myrl-saki> Mhm.
10:51 <biglambda> Wow, that’s a mess
10:52 xificurC joined
10:52 <Myrl-saki> In C, that would be..
10:52 <EvanR> from what i understand, protocols tend to avoid this by encoding the float in "textual" form, possible in hex notation
10:52 <Myrl-saki> (1 << msize) | m
10:52 <Myrl-saki> For the mantissa.
10:52 <EvanR> then it doesnt matter what either side needs
10:52 <Myrl-saki> And the sign wolud require you to use if/else.
10:53 <Myrl-saki> :t bool
10:53 <lambdabot> a -> a -> Bool -> a
10:53 <Myrl-saki> bool 1 2 True
10:53 <Myrl-saki> > bool 1 2 True
10:53 <lambdabot> 2
10:53 sepp2k joined
10:54 <EvanR> > floatToDigits 16 3.14
10:54 <lambdabot> ([3,2,3,13,7,0,10,3,13,7,0,10,3,14],1)
10:54 jer1 joined
10:55 <EvanR> not space efficient but avoids endianness encoding issues
10:55 <mniip> biglambda, well, imagine running your haskell code on a machine that doesn't use IEE754 floats
10:55 <mniip> you would have to implement IEEE754 in one way or another
10:55 <Myrl-saki> biglambda: encodeFloat (bool id negate sign $ 1 `shiftL` msize .|. m) exp
10:56 <mniip> that's wrong
10:56 <EvanR> Myrl-saki: this is assuming little endian? or
10:56 <Myrl-saki> EvanR: No assumption on the encoding.
10:56 <Myrl-saki> Rather.
10:56 <EvanR> uh
10:56 <Myrl-saki> It's encoding agnostic.
10:57 <Myrl-saki> mniip: Care to say why it's wrong?
10:57 <EvanR> with a Word32 or Word64, i think it does
10:57 <EvanR> well at the time you convert from [Word8] to one of those
10:57 <Myrl-saki> EvanR: That's assuming processing already.
10:57 <mniip> > decodeFloat (-3)
10:57 <lambdabot> (-6755399441055744,-51)
10:57 <mniip> ok, maybe not
10:58 plot joined
10:58 Yuras joined
10:58 <EvanR> http://hackage.haskell.org/package/data-binary-ieee754-0.4.4/docs/Data-Binary-IEEE754.html
10:58 coot____ joined
10:59 mmachenry joined
10:59 soniku joined
11:00 <EvanR> read 4 bytes with attoparsec, then parse that with binary (and this add on lib), which technically cant fail
11:01 <EvanR> any pattern of 4 bytes is "valid"
11:01 <biglambda> I see
11:01 <biglambda> That’s a good find thank you
11:01 netheranthem joined
11:02 <mniip> > decodeFloat (1e-315)
11:02 <lambdabot> (6791492634935296,-1099)
11:02 oisdk joined
11:02 Snircle joined
11:02 fotonzade joined
11:02 wroathe joined
11:02 <EvanR> or if you have the Word32 patched together already, theres quicker methods for that.
11:03 <EvanR> which is a pain in the ass in itself
11:03 rcat joined
11:03 Boomerang joined
11:08 oisdk joined
11:08 sproingie joined
11:10 <mniip> where's all the type theory folk :o
11:11 <EvanR> probably ##typetheory
11:11 <mniip> I have a concept of an idea of a typesystem extension
11:11 <EvanR> oh, you mean applied type theory ;)
11:11 <mniip> well, GHC type theory
11:11 <opqdonut> #ghc?
11:12 <mniip> idunno
11:13 richi235 joined
11:14 aib joined
11:14 <pacak> mniip: Try haskell-cafe mailing list?
11:15 <mniip> yeah I was just thinking about that
11:15 jer1 joined
11:15 <mniip> but it's at a such a concept stage that it is entirely possible that I'm missing some obvious detail
11:16 newhoggy joined
11:17 zeroed joined
11:17 sdothum joined
11:21 tobiasBora joined
11:21 merijn joined
11:21 MarioBranco joined
11:22 Swizec joined
11:22 aglorei joined
11:24 Chong joined
11:24 Rodya_ joined
11:24 <Chong> how can I set up my directory structure for a project?
11:24 <Chong> I have two files in src/Tables
11:24 <Chong> one of them imports the other
11:25 <Chong> but it can't find it
11:25 seveg joined
11:25 <merijn> Chong: How are you compiling?
11:26 <Chong> I'm not compiling anything
11:26 <Chong> only using runhaskell
11:26 <bartavelle> what does "to a T" mean in "That's been my experience with Haskell to a T" ?
11:27 <Chong> means it's an accurate descroption
11:27 <bartavelle> (more an English than a Haskell question, but well)
11:27 <bartavelle> thanks
11:27 <bartavelle> oh I thought that was a pun I didn't get, I should have just googled "to a T" :/
11:28 <merijn> Chong: Ah, in that case step one should be to stop using runhaskell and start compiling using either cabal or stack :)
11:28 <Chong> so I have two files in src/Tables
11:28 <merijn> (Everyone seems to recommend stack for beginners, but I'm not familiar with it)
11:28 <Chong> Bid.hs and Go.hs
11:29 <Chong> Ithe modules are called Tables.Bid and Tables.Go
11:29 <Chong> I try to import Tables.Bid from tables.Go and ti doesn't work
11:29 <EvanR> ive seen beginners recommend stack to each other, and beginners struggle with stack
11:29 <EvanR> im like, try cabal by itself
11:29 <Chong> but if I rename the module to just Go then I can't import it from any files in src/
11:30 moet joined
11:30 AndreasK joined
11:31 coot____ joined
11:31 asmyers joined
11:32 cfricke joined
11:33 jeltsch joined
11:33 tsmish joined
11:33 wroathe joined
11:34 butterthebuddha joined
11:36 seveg joined
11:36 jer1 joined
11:36 blym joined
11:36 laserpants joined
11:36 orhan89 joined
11:37 <merijn> Chong: As soon as you have multi-module programs you'll want to use cabal or stack to compile them for you
11:37 fendor joined
11:38 zeroed joined
11:38 <cocreature> both use cabal project files so the question of how to organize your project is largely independent of whether you use cabal or stack
11:39 danthemyth joined
11:39 <merijn> cocreature: Yes, but I'll get badgered by the "Stack Evangelism Strike-Force" if I tell people to use cabal :p
11:39 <laserpants> Is it possible to use MathJax or some sort of LaTeX in Haddock now, or how is it? When generating HTML I mean.
11:39 <merijn> Not AFAIK?
11:39 <cocreature> merijn: I wasn’t trying to correct you. I was just expanding on your answer :)
11:39 <cocreature> it definitely is
11:40 <cocreature> laserpants: the docs are here https://github.com/haskell/haddock/pull/525/files
11:41 <laserpants> cocreature: Thanks. I remember reading about it somewhere.
11:41 <mniip> what was the word
11:41 <cocreature> mniip: huh?
11:42 <mniip> the kind of equality that means that two functions are equal if their outputs are equal on all inputs
11:42 <cocreature> extensional equality
11:42 <mniip> uhh no
11:42 <cocreature> or functional extensionality
11:42 <EvanR> funext
11:42 <mniip> hm, maybe extensional is an even better word than what I had in mind
11:43 <cocreature> I didn’t make this up, it’s a standard term :)
11:44 coot____ joined
11:45 obadz joined
11:46 mjo joined
11:49 jaspervdj joined
11:54 coot_____ joined
11:54 fotonzade joined
11:56 guampa joined
11:59 ziocroc joined
12:00 jer1 joined
12:02 tomphp joined
12:05 wroathe joined
12:06 nomicflux joined
12:06 <Kototama> what is the equivalent of cataM (purescript) in Haskell?
12:06 <EvanR> foldM ?
12:06 <EvanR> :t foldM
12:07 <lambdabot> (Monad m, Foldable t) => (b -> a -> m b) -> b -> t a -> m b
12:08 <Kototama> is foldM top down or bottom up?
12:08 theorbtwo joined
12:08 <cocreature> that depends on your Foldable instance
12:08 oisdk joined
12:09 <Kototama> so you cannot have both
12:09 <cocreature> at least not without newtypes
12:10 simukis_ joined
12:11 Yuras joined
12:11 FrankZappa joined
12:12 cchalmers joined
12:13 valdyn joined
12:13 <Kototama> But how do you make it top or bottom if the type is something like that: data Exp a = Num Int | Mul [a] ?
12:15 <cocreature> I just use manual recursion like a peasant
12:15 <cocreature> :)
12:15 tobiasBora joined
12:17 <Kototama> :)
12:17 <Kototama> i wish i could
12:17 <cocreature> Kototama: there is a recursion-schemes package that might be interesting to you
12:18 <Kototama> yeah i'm more or less using the equivalent in purescript but asking here because they sleep in the purescript channel :)
12:19 jer1 joined
12:19 qwr joined
12:20 <Kototama> not just sure how i could say "eh take the parent first" in foldMap f (Mul children) = foldMap f children since the parent has no value to put in the fold
12:20 JeanCarloMachado joined
12:24 ragepandemic joined
12:25 Rodya_ joined
12:25 <mniip> pacak, tadaa https://mail.haskell.org/pipermail/haskell-cafe/2017-April/126893.html
12:29 fakenerd joined
12:30 tommd joined
12:30 crobbins joined
12:31 ortmage joined
12:31 Maxdamantus joined
12:32 lachtara joined
12:33 newhoggy joined
12:33 ziocroc joined
12:33 kmels joined
12:34 fizbin joined
12:34 <pacak> mniip: Hmm... I think there was a reason behind not allowing partial application in type families, but we'll see
12:35 <mniip> I mentioned that in my post
12:35 xtreak joined
12:35 cschneid_ joined
12:36 xtreak joined
12:36 wroathe joined
12:39 doomlord joined
12:40 ExpHP joined
12:40 jer1 joined
12:40 av joined
12:40 <ij> Are functions bifunctors?
12:41 <EvanR> profunctors
12:41 <EvanR> the left hand side is contravariant
12:41 newhoggy joined
12:41 <mniip> oh
12:41 <* mniip> read "functors"
12:42 oisdk joined
12:42 splanch joined
12:42 coot_____ joined
12:42 <ij> Ok, now I see that it couldn't be made to work with bifunctor.
12:42 <mniip> ij, if they were bifunctors, then you would have a mapping (a -> b) -> ((a -> c) -> (b -> c))
12:43 Maxdamantus joined
12:43 psychicist__ joined
12:44 <laserpants> When using stack repl (or cabal repl), is there a way to reload the cabal file without exiting?
12:45 <laserpants> For example, if I change "exposed-modules" in the library settings.
12:45 <bennofs> laserpants: pretty sure there is not
12:46 <laserpants> ok.
12:47 zachary12 joined
12:48 phaji joined
12:49 JonReed joined
12:49 <qwr> Hi. Given a lexer/parser written in alex/happy, I'd like a Show instance for the ast such that calling "show" results in (more or less) the parser input. Are there any tools/packages/... that can help me with that?
12:50 <merijn> qwr: Well, that's not a job for Show
12:50 <merijn> qwr: Show should print valid Haskell
12:50 <merijn> qwr: You want one of the 20 or so pretty-printing libraries on Hackage
12:50 jeltsch joined
12:50 <merijn> quchen: If you stopped slacking I could recommend yours! :p
12:51 blender3 joined
12:51 takle joined
12:52 mmn80 joined
12:53 wroathe joined
12:54 nickager joined
12:55 <davean> qwr: Show is usually the actual Haskell data.
12:55 <davean> qwr: its at least supprising, if not bad form, to use show inconsistent with that
12:55 <MonadHendrix> is it bad for to use Show as a quick n dirty pretty printer
12:56 <EvanR> if theres a function in my record, i would rather see everything else than an error
12:56 tomphp joined
12:56 Yuras joined
12:56 <davean> EvanR: thats phylisophically in line with Show though
12:56 <quchen> merijn: Yes yes
12:56 <qwr> Okay, then I'll stop doing that. :) But still: "How do I pretty-print what I have parsed with alex/happy?"
12:57 <EvanR> huh
12:57 meba joined
12:57 <davean> EvanR: at least in my mind
12:57 <mniip> quchen, merijn, any comments :o https://mail.haskell.org/pipermail/haskell-cafe/2017-April/126893.html
12:57 <quchen> merijn: I’m still working on it occasionally. I just pushed another important change (namely exposing the Doc type in an Internal module so people can write adaptors)
12:57 fizbin joined
12:57 <merijn> \o/
12:58 plot joined
12:58 <merijn> mniip: Partial type family application is equivalent to type level lambda's, which would make type checking undecidable
12:58 <merijn> mniip: Which is why it's not possible atm
12:59 <mniip> did you even read :v
12:59 <merijn> mniip: I was just reading after skimming :p
13:00 <merijn> mniip: I don't feel qualified to comment on the impact of type safety of that :)
13:00 butterthebuddha joined
13:00 Voldenet joined
13:00 Voldenet joined
13:01 matrium joined
13:01 mthek joined
13:01 unyu joined
13:02 Swizec joined
13:02 Hamlet joined
13:03 Swizec joined
13:03 Swizec joined
13:05 baldrick joined
13:05 ystael joined
13:06 <matrium> hi, I have a constrained type parameter in some of my functions (e.g. usingEntities :: Rdf a => RDF a -> Node -> [Node]). I now want to refactor the "Rdf a => RDF a" parameter into a reader monad. Can I somehow create a type like "type RDFReader a = Rdf r => Reader (RDF r) a"?
13:06 <quchen> merijn: Is it, though? Why? Don’t we have kinds, giving us a simply-typed lambda calculus, which is strongly normalizing?
13:07 biglambda joined
13:07 <ski> matrium : i think you'd want a `forall r.' in there
13:08 <merijn> quchen: eh...I thought about this long and hard 1 or 2 years ago and only remember my conclusion >.>
13:08 wroathe joined
13:08 alfredo joined
13:09 slemonide joined
13:09 fendor joined
13:09 sproingie joined
13:09 <ski> matrium : alternatively, you could encode an existential ..
13:10 dbmikus joined
13:12 iAmerikan joined
13:14 sgronblo joined
13:16 <matrium> ski: thanks! "type RDFReader a = forall r . Rdf r => Reader (RDF r) a " works for me
13:16 doomlord joined
13:17 <lpaste> Hamlet pasted “Find largest prime factor of 600851475143” at http://lpaste.net/354943
13:18 <ski> matrium : you might need to enable higher-rank types .. if you use that type synonym in an argument position. but possibly you won't need that
13:18 <Hamlet> Hello #haskell, can anyone help me with the following code? Thanks.
13:18 <Hamlet> http://lpaste.net/354943
13:19 splanch joined
13:20 <mniip> where do I start
13:20 <quchen> merijn: We don’t have a Void-kind, do we?
13:20 tobiasBora joined
13:21 <quchen> Meh, not sure if that is related. Nevermind.
13:21 jathan joined
13:21 hackebeilchen joined
13:22 <mniip> :k Foo -- quchen
13:22 <lambdabot> Void -> *
13:22 <mniip> it behaves nothing like Void though
13:22 <ski> Hamlet : variable names can't start with an upper case letter. change `N' to `n' ?
13:23 <quchen> mniip: That’s nod of kind Void, it’s of kind ->.
13:23 cdg joined
13:23 <quchen> nod...yeah right
13:24 <Hamlet> If you can list the mistakes I can change one by one directly. Thanks
13:24 <ski> Hamlet : `(isPrime n == True)' can be simplified to just `isPrime n'. `isPrime n' will already compute to a boolean (a truth-value, `True' or `False'). no need to compare it with `True', only to get back the same truth-value again
13:24 danthemyth joined
13:24 <ski> Hamlet : that's what i'm doing :)
13:24 <mniip> quchen, the argument of Foo has kind Void
13:24 richi235 joined
13:25 plutoniix joined
13:25 <ski> Hamlet : in the definition of `isPrime', no need to use a boolean expression guard (and `otherwise' in the other case), only to return either `True' or `False'. simply directly return the boolean expression (after the `='), not using any guards (the `| ...' stuff)
13:26 MarioBranco joined
13:26 plutoniix joined
13:26 Rodya_ joined
13:26 newhoggy joined
13:26 <ski> Hamlet : `isFactor x = (n `mod` x == 0)' could be just `isFactor x = n `mod` x == 0', no need for that extra pair of brackets
13:27 <ski> Hamlet : in `main', either put the `let n = ...' after the `do' .. or else define it after a `where' at the end. also you need to indent `then' and `else' more, and line up `print' with `if'
13:27 <c_wraith> ski: I once saw a person put (== True) in a chain of composed functions, and couldn't convince them it was the same as id.
13:28 <* ski> smiles
13:28 <quchen> mniip: Oh, right. But is it really uninhabited? I mean you can easily create a new kind called »Void«
13:28 <mniip> it is inhabited by forall a.a
13:28 <EvanR> they probably were denying principle of function extensionality
13:29 <ski> Hamlet : however, in Haskell, you can't put variable bindings in the `then'&`else' branches of an `if', and expect them to be in scope "after" it. instead, you can use `let largestPrimeFactor = if ... then ... else ...' (broken down over multiple lines, indented properly, if you prefer)
13:29 fendor joined
13:30 <ski> well, `seq id ()' is equal to `seq (== True) ()', so the function extensionality problem shouldn't apply ..
13:32 <ski> Hamlet : in the definition of `findLargestPrimeFactor', `if (True) then ..something.. else ..alternative..' is equivalent to just `..something..', skipping the `if' and the `else'-branch. but i suspect this isn't what you wanted
13:32 crobbins joined
13:32 jangsutsr joined
13:33 <ski> Hamlet : just before the `if', you have a command in the `do'-block that's `isPrime n'. presumably you wanted to either put this condition in the `if' ? or else, possibly name the result of that expression, and then put that variable name in the `if' ?
13:33 sproingie joined
13:34 orhan89 joined
13:34 newhoggy joined
13:34 fbergmann joined
13:35 cschneid_ joined
13:35 <Hamlet> do-block for which function?
13:35 <ski> <ski> Hamlet : in the definition of `findLargestPrimeFactor', ...
13:35 <ski> Hamlet : here again, you have the `then' branch consisting of a `let' (without an `in'), but this time no such thing in the `else' branch. instead you have a further `let' command after the whole `if'-`then'-`else'. it's not clear what you intended here, elaborate ?
13:35 dfeuer joined
13:36 Argue_ joined
13:36 Aruro joined
13:36 soniku joined
13:36 Kreest__ joined
13:36 <ski> Hamlet : one further problem i can see is that your definition of `findLargestPrimeFactor' accepts a list of numbers, but in `main', you're calling `findLargestPrimeFactor' with a single number, not a list
13:36 Apocalisp joined
13:37 <Hamlet> - Let me read up more on syntax, clear up the mistakes you've pointed to.. then I'll return to this channel again.- Thanks for the help so far. Regards
13:38 <ski> Hamlet : oh, it also looks like `main' expects that `findLargestPrimeFactor' will return a number (judging from you naming the result `largestPrimeFactor' in `main'), but in the first defining equation of `largestPrimeFactor', you're returning a list (specifically, the empty list)
13:38 dylukes joined
13:38 <ski> (it's not clear what you intended to return in the second defining equation of `largestPrimeFactor' ..)
13:39 `^_^v joined
13:39 Wuzzy joined
13:40 wroathe joined
13:41 eacameron joined
13:43 pavonia joined
13:43 dzdcnfzd joined
13:44 cpup joined
13:44 cdg_ joined
13:44 newhoggy joined
13:44 uwap joined
13:46 <dzdcnfzd> I'm trying to get through Stephen Diehl's vim 2016 advice and running into troubles with `stack install ghc-mod`. The errors are here: http://lpaste.net/354949. Any suggestions?
13:47 cpennington joined
13:47 carlomagno1 joined
13:47 eschnett joined
13:48 sabali_ joined
13:49 cdg joined
13:49 <quchen> dzdcnfzd: Is your LTS release too old?
13:49 <MarcelineVQ> it tells you what to do dear. but you're usually better off using it per project, so in your project you'd type stack build ghc-mod and to use it you'd go stack exec ghc-mod
13:49 mmachenry joined
13:49 <quchen> What does your stack.yaml say in the »resolver« field, dzdcnfzd?
13:49 sabali joined
13:49 luminousnine joined
13:49 <MarcelineVQ> also like quchen suggests you may want to bump up your lts version in the stack.yaml file it mentions
13:49 cdo joined
13:50 cdo left
13:50 <dzdcnfzd> resolver: lts-3.19
13:50 <quchen> That’s ooold
13:50 <quchen> Current is 8.something
13:50 cdg_ joined
13:50 <quchen> Stackage did not use to include that many packages
13:50 <dzdcnfzd> quchen: is there an automated update process I should be doing?
13:50 Costar joined
13:50 <dzdcnfzd> I just did stack update with no effect
13:50 <quchen> dzdcnfzd: Just replace the string in your stack.yaml
13:51 <quchen> And go again
13:51 <Aruro> dzdcnfzd: did u recently installed ghc and stack?
13:51 sgflt joined
13:51 <Aruro> dzdcnfzd: stack update does not much help, better clean reinstall
13:51 <dzdcnfzd> Aruro: no, not as I recall
13:51 <MarcelineVQ> Aruro that's unlikely to help
13:51 luminousnine left
13:51 <Aruro> dzdcnfzd: what is version of ghc and stack?
13:52 <dzdcnfzd> MarcelineVQ: so in this case, just download the vim repo, build the executable, and add it to my path?
13:52 <Aruro> ghc-mod couples with specific ghc version
13:52 <dzdcnfzd> or is there a general way to stack install for the whole system using particular code?
13:52 <dzdcnfzd> (sorry -- I should know this stuff better. Dev environment has never been my strongpoint)
13:53 <Aruro> dzdcnfzd: yes global configuration is what stack will do if not in project dir
13:53 <Aruro> dzdcnfzd: if u did not waste much time yet, i suggest clean reinstall of everything with new versions
13:53 newhoggy joined
13:53 <Aruro> ghc+cabal+stack, and then repeat stack install ghc-mod
13:54 <MarcelineVQ> you can install it globally but it becomes a problem because ghc-mod expects specific library versions depending on what it was built with as Aruro mentions, which is why it's best to build it per project since each project will have its own lts version and thus its own specific library version ranges
13:54 coot joined
13:54 <dzdcnfzd> MarcelineVQ: are the libraries dynamically or statically linked?
13:55 <Aruro> dzdcnfzd: last but not least are u sure u alread need ghc-mod? maybe hlint will suffice on this level?
13:55 <MarcelineVQ> idk about that, it's more about brittle api than linkage I think
13:55 <dzdcnfzd> This is sort of a big question, but why isn't it possible to stack install a bunch of things globally with different deps?
13:55 <MarcelineVQ> if there's a vim plugin that invokes ghc-mod for you hopefully it knows to check your stack paths first, in which case stack build ghc-mod from your project's directory would be enough to have ghc-mod work for your project
13:56 <dzdcnfzd> MarcelineVQ: oh, really!?
13:56 iomonad joined
13:56 <MarcelineVQ> well I don't use vim but atom and emacs have plugins that work that way
13:57 <Aruro> dzdcnfzd: if u are into ide, people say intero is good, but im not sure its for vim
13:57 <MarcelineVQ> it's not a big question exactly, but the answer is the point of stack so my reponse would be to read the docs :>​https://docs.haskellstack.org/en/stable/GUIDE/
13:57 mizu_no_oto_work joined
13:58 Yuras joined
13:58 chlong joined
13:58 <dzdcnfzd> Aruro: I'm not looking for an IDE. I'm a regular vim-user, but working with an IDE for work for about two years has fairly well convinced me that on-the-fly type info and the like is enormously useful
13:58 descender joined
13:58 <MarcelineVQ> neo vim has an intero plugin iirc
13:58 <dzdcnfzd> MarchelineVQ: thanks -- will do
13:59 <Aruro> yes i have seen haskellers use neovim
13:59 <dzdcnfzd> I'm trying to just use SDiehl's setup
13:59 <Aruro> and brag that there are some good plugins for it
13:59 <MarcelineVQ> If you can't manage to get ghc-mod working for you I'd try intero if you want mouse-over checking, and be sure to try out ghcid if all else fails because it's pretty good too
13:59 <dzdcnfzd> What is this weird world where people try to convince someone not to use VIM
13:59 mmhat joined
13:59 <dzdcnfzd> am I in the future?
14:00 <Aruro> hm, neovim is not vim?
14:00 <MarcelineVQ> I've personally moved away from ghc-mod to mostly using ghcid just because it's a bit of a memory hog and a little brittle
14:00 <MarcelineVQ> I should learn emacs like a good little rabbit but life is only so long
14:01 <dzdcnfzd> Aruro: I was referring to intero :)
14:01 <dzdcnfzd> MarcelineVQ: will check out ghcid
14:01 mada joined
14:02 featherlessbiped joined
14:03 sabali_ left
14:03 fendor joined
14:03 <Aruro> dzdcnfzd: type indication on fly is good, but from my experience its not that big deal
14:03 infinity0 joined
14:04 <Aruro> flycheck i think is much better
14:04 <dzdcnfzd> Also, random question that really belongs in the vim irc, but I just got all of Stephen Diehl's vim config, and backspace stopped working in insert mode. Anyone ever seen anything like this? Know what plugin or setting might be causing it?
14:04 <MarcelineVQ> I found it really helpful while still learning how types fit together, now not so much
14:04 <dzdcnfzd> Aruro: Don't know what flycheck is
14:05 <dzdcnfzd> Also, what MarcelineVQ said is exactly right. I'm still building up intuition about a lot of stuff -- it's either on-the-fly type checking or really painstakingly putting together the types myself
14:05 newhoggy joined
14:06 <dzdcnfzd> On a monad-transformer-stack where I'm screwing something up and I don't know why, I'd rather just be able to ask a compiler
14:07 <glguy> i find the fly check type errors are only useful when you know how to fix things just by being told where the problem is
14:07 <MarcelineVQ> > Just "some type" :: _tellmeyoursecrets -- you can annotate too to get type info
14:07 <lambdabot> error:
14:07 <lambdabot> • Couldn't match expected type ‘_tellmeyoursecrets1’
14:07 <lambdabot> with actual type ‘Maybe [Char]’
14:07 <glguy> if you want to read the whole message it's a bit cramped
14:08 <Hamlet> Revised code:
14:08 <lpaste> Hamlet pasted “Find largest prime factor of 600851475143” at http://lpaste.net/354950
14:08 electrostat joined
14:08 coot joined
14:08 <glguy> but it's not a replacement for having to understand the types of things
14:10 <Aruro> glguy: yes that was my point, that interactive types are not that useful at the end
14:10 HoierM joined
14:10 ChristopherBurg joined
14:10 tobiasBora joined
14:11 <Aruro> especially when u add new libs ghc-mod starts to brake or can not find type, and mess starts
14:11 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
14:11 <MarcelineVQ> that problem doesn't happen if you build and run it per-project
14:12 <MarcelineVQ> But it's often still a fair memory hog
14:12 <shapr> Tools are never a replacement for understanding.
14:13 Nazzr joined
14:13 eklavya joined
14:13 newhoggy joined
14:14 <Aruro> flycheck helps to be certain that everything u wrote so far is not complete nonsense, and this feeling is kinda helpful
14:14 <Aruro> at least for me.
14:15 pungi-man joined
14:15 <MarcelineVQ> dzdcnfzd: iirc hlint does the job of flychecking for ghc-mod which is why stephen has you install them together
14:15 infinity0 joined
14:15 jer1 joined
14:15 <ski> Hamlet : still redundant brackets, on lines `11',`21',`25',`31'. if you indent the `if' on line `31' (and following lines belonging to it) more, then you can omit the curly brackets there. also remove `largestPrimeFactor = ' from both branches. you already have a `let largestPrimeFactor = ' on line `30' that will receive the value of the whole `if'-expression
14:16 cpennington joined
14:16 dsh joined
14:16 newhoggy joined
14:17 richi235 joined
14:19 Costar joined
14:20 simendsjo joined
14:20 orhan89 joined
14:21 newhoggy joined
14:22 alfredo joined
14:23 ignatiz- joined
14:23 sgronblo joined
14:23 paroxp joined
14:26 <Squarism> Ive got a <<loop>> error. What is a good way of approaching that? It could be one of atleast 8 threads
14:26 bodisiw joined
14:26 <edwardk> mniip: 5 hours later, yeah =)
14:26 <Squarism> ...other than sprinkle code with trace statements
14:26 <mniip> edwardk, https://mail.haskell.org/pipermail/haskell-cafe/2017-April/126893.html
14:26 Rodya_ joined
14:27 wroathe joined
14:28 <edwardk> in ermine we have something we half-jokingly call "really liberal type synonyms" where you can use partial application of `type`s, inside other type declarations, so long as when the whole thing is finally inlined at the use site it is fully saturated.
14:28 <lyxia> Squarism: compile with profiling, +RTS -xs https://wiki.haskell.org/Debugging results not guaranteed.
14:28 vaibhavsagar joined
14:29 sellout- joined
14:29 <edwardk> anyways re your proposal I'm going to shrug and say I don't have any idea how sound it is. =)
14:29 kuribas joined
14:29 <edwardk> i know the somewhat weaker thing we use is sound
14:30 <Squarism> lyxia, thanks. Will try that
14:30 <ski> edwardk : how does that differ from `LiberalTypeSynonyms' in GHC ?
14:30 qwr left
14:31 <dzdcnfzd> Aruro: do you have any resources for fully removing stack?
14:31 <dzdcnfzd> got rid of all my .stack-work dirs
14:31 <dzdcnfzd> want to make sure I've got nothing else
14:31 seangrove joined
14:32 al-damiri joined
14:33 <edwardk> https://www.irccloud.com/pastebin/Tlz9eEjD/ReallyLiberalTypeSynonyms
14:34 ralu joined
14:34 plakband joined
14:34 <plakband> Is there anyone here who has succesfully built repa with llvm on windows?
14:34 burtons joined
14:34 jer1 joined
14:35 <ski> .. i tend to think of `LiberalTypeSynonyms' in terms of staged programming, or higher-order macros
14:35 tobiasBora joined
14:36 <ski> e.g. at <https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#liberalised-type-synonyms>, i think of `Generic' has having kind `(<*> -> <*>) -> (<*> -> <*>) -> <*>'
14:37 <ski> `Id' having kind `<*> -> <*>', while `[]' has kind `<* -> *>', but it can be construed has having the former kind. so `Generic Id []' has kind `<*>'
14:38 tommd joined
14:38 thang1 joined
14:39 oleo joined
14:39 oleo joined
14:40 egis joined
14:40 <ski> the idea being that `type Foo a = a -> a -> Bool' is thought of as `type Foo a = <{a} -> {a} -> Bool>', while an application `Foo (forall b. b -> b)' is thought of as `{Foo <forall b. b -> b>}'. `<...>' being quasiquotation and `{...}' unquotation
14:41 refold joined
14:41 shivansh joined
14:41 shivansh left
14:41 crobbins joined
14:41 govg joined
14:42 <mivael> Good news: attoparsec is great :) and I'm now acquainted enough with it to make it work! http://codepad.org/SQWA7OXP
14:42 newhoggy joined
14:42 <mivael> Bad news: competitive programming sites seem to not like attoparsec: http://codeforces.com/contest/456/submission/26683927
14:43 wroathe joined
14:43 <merijn> mivael: line 51 has redundant parens on both sides of the : :)
14:43 <mivael> "Data.Attoparsec.ByteString.Lazy: Can't be safely imported! The module itself isn't safe."
14:43 <mniip> good on them
14:43 <mniip> the module really isn't safe
14:44 <mivael> mniip, in what sense?
14:44 <ski> edwardk : ok, so the definiens (and definiendum) of a `type' declaration wouldn't necessarily have to be "concrete" (/ saturated)
14:44 <mniip> mivael, in safehaskell sense
14:44 <edwardk> ski: yeah
14:44 <mniip> mivael, as in, can be run in sandbox
14:44 <Squarism> dzdcnfzd, why escape from stack? I thought it was the best option out there
14:44 <mniip> lambdabot, for example, runs haskell code on a real machine
14:44 <mniip> only a set of 'safe' functions is available however
14:45 <mniip> those safe functions are managed by SafeHaskell
14:45 <mniip> it naturally excludes things like unsafeCoerce, unsafePerformIO
14:45 <merijn> edwardk: How come I've never before heard of you structs package? :O
14:45 <edwardk> merijn: i wrote it on a weekend, gave a 5 minute talk then put it away =P
14:46 jimmyrcom joined
14:46 <merijn> edwardk: Looks like the kinda thing I desperately want in Haskell :p
14:47 <merijn> Unrelatedly, I wish base had a convenient name for "flip when"
14:47 Hamlet joined
14:48 <mivael> mniip, what parse library should one use instead of attoparsec, then, in competitive programming context (large number of input should be parsed rather fast)?
14:48 <mniip> what is the input
14:49 Hamlet joined
14:50 <mivael> mniip, say, 100000 decimal integers from stdin (can be not just integers, ascii char strings are also possible, depending on specific problem)
14:50 <mniip> have you timed 'map read . lines . getContents'
14:50 pera_ joined
14:50 Hamlet joined
14:51 cpennington joined
14:51 <mivael> mniip, yes... I can provide a couple of links to my practice submissions on codeforces
14:52 jao joined
14:53 HarveyPwca joined
14:53 <mivael> fast haskell version (bytestring): http://codeforces.com/contest/456/submission/26607428
14:53 <mniip> dfeuer, before I embarass myself on the list, what exactly is the problem with nullary/dependent families
14:54 fendor joined
14:54 NanZhang joined
14:54 <mniip> nullary families can be reduced immediately
14:54 <mivael> slow haskell version (interact $ unlines . map show . solveMany . map read . words): http://codeforces.com/contest/456/submission/26607734
14:54 <mniip> also equality usually has a kind in which it is conducted
14:55 <mniip> which can be used to reduce dependent families
14:55 <dfeuer> mniip: what about class instances?
14:55 <mivael> fast C++ version (same algorithm): http://codeforces.com/contest/456/submission/26591537
14:55 jer1 joined
14:56 <mivael> mniip: 124 ms, 514 ms, and 62 ms correspondingly
14:56 <dfeuer> mniip: I'm just pointing out that using a funny arrow doesn't seem to distinguish constructors from families in all cases.
14:57 <mniip> dfeuer, it can be used to distinguish equatable from inequatable types
14:57 nicknovi1 joined
14:57 stevenxl joined
14:57 <mniip> since that was the problem with partially applied families
14:57 <mivael> mniip, the "fast haskell version" (124 ms) is okay regarding speed, but I did not like the souce code -- so I was advised to try attoparsec.
14:57 stevenxl joined
14:57 stevenxl joined
14:57 <mivael> s/souce/source/
14:57 <mniip> mivael, well, you can't go much faster without bytestring
14:57 sproingie joined
14:57 sproingie joined
14:58 sz0 joined
14:58 <dfeuer> mniip: I don't know enough about it, perhaps. That was just my concern when I was thinking about the idea; it doesn't mean there's a real problem necessarily.
14:58 teggi joined
14:58 <mniip> if your algorithm is N log N or better haskell is going to drag you down a lot if you stick to Safe
14:58 newhoggy joined
14:58 <mniip> dfeuer, thanks for the input though
14:58 <mivael> mniip, I know. But I wanted the code be more fancy and easier to memorize/retype/etc
14:58 NeverDie joined
14:58 <mniip> dfeuer, I was told goldfire is going to do typesystem stuff this summer
14:58 wroathe joined
14:59 featherlessbiped joined
14:59 thang1 joined
14:59 plot joined
14:59 <ski> mniip : .. i wonder how far the "staged programming" idea could be taken here
14:59 crobbins joined
14:59 <mniip> ski, ?
14:59 iqubic joined
15:00 <iqubic> Hello guys.
15:00 <ski> basically the idea that `type' synonyms should be treated as macros, or staged programming
15:00 <mniip> ah
15:00 <ski> and that `LiberalisedTypeSynonyms' then could be seen as allowing (at least some forms of) higher-order "macros"
15:00 <ski> <ski> e.g. at <https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#liberalised-type-synonyms>, i think of `Generic' has having kind `(<*> -> <*>) -> (<*> -> <*>) -> <*>'
15:00 thang1 joined
15:01 coot joined
15:01 <iqubic> What is a macro? What does it mean in haskell
15:01 <ski> (it would help here if you were a bit familiar with MetaML/MetaOCaml .. or at least staged programming (or macros) in the Lisps)
15:02 <mniip> iqubic, nothing and nothing
15:02 <mivael> mniip, is Parsec safe by the way? And could it be used with ByteString to achieve better I/O/parsing speed?
15:02 <mniip> we are hypothesizing type system changes
15:02 <ski> "macro" here is used as a syntactic short-hand for staged programming
15:02 <dzdcnfzd> Squarism: not escaping -- just installing clean
15:02 <mniip> mivael, I'd have to check
15:02 <ski> the idea being that type synonym application is not the same thing as type constructor application
15:03 <mivael> mniip, I'll check it some time later
15:03 <iqubic> ski: What is staged programing?
15:04 <ski> iqubic : programs that write programs. also sometimes programs that analyze programs
15:04 newhoggy joined
15:04 <iqubic> That sounds hard.
15:04 <ski> specifically i'm thinking of some kind of quasiquotation and unquotation mechanism
15:04 <iqubic> Wow.
15:05 xall joined
15:05 <ski> anyway .. i'm not really suggesting a full-blown such system here. only that it may be that type synonyms may be gainfully understood in this sense
15:06 <ski> one could embed and construct snippets of language B in language A using such quasiquotation. that's heterogenous staged programming
15:06 <mivael> merijn, I know :) I thought it is more readable with parentheses
15:06 <ski> one could also embed snippets of the same language in itself. that's homogenous staged programming. which naturally then also needs to possibly having more than two stages
15:07 <ski> anyway, `ReadS (Maybe Integer)' would be elaborated by a binding-time analysis into really saying `{ReadS <Maybe Integer>}'
15:07 flatmap13 joined
15:07 <ski> `<...>' is here quotation. `{...}' is unquotation
15:07 <mivael> merijn, by the way, the ones to the left of ':' are needed as it seems (note the '$' inside)
15:08 <ski> so what this means is that the application `ReadS <Maybe Integer>' runs and simplifies at *compile*-time (or, macro-expansion-time, or type-synonym-expansion-time, if you prefer)
15:08 <merijn> mivael: Yeah, I realised that later, but I'd probably replace that $ with () then :)
15:08 richi235 joined
15:08 bvad joined
15:09 <dolio> merijn: Did you want something from me yesterday?
15:09 <merijn> dolio: I think I recall you mentioning writing criterion benchmarks for vector-algorithms, right?
15:09 <ertes> we could also unify the type language with the value language =)
15:09 <ertes> Blah :: Type
15:09 <ertes> Blah = Integer
15:10 <ski> iqubic : a standard example is writing a version of exponentiation, with a natural number exponent (say), which simplifies away the exponentiation at compile-time. this assumes that the exponent is given statically, naturally
15:10 <merijn> dolio: And having problems for things like sorting, since it doesn't have per-run environments
15:11 xificurC joined
15:11 <dolio> Yes.
15:11 markasoftware joined
15:11 willprice joined
15:11 <merijn> dolio: So, yesterday I finally finished up and made a PR (still lacking some tests and a tiny bugfix relating to <* not being in Prelude for old GHCs), so I wanted to ask if you could have a look whether the interface works for your usecase and if yes, help me badger people into getting it merged
15:11 <merijn> dolio: https://github.com/bos/criterion/pull/136
15:12 newhoggy joined
15:12 <dolio> Okay, cool. I'll take a look.
15:12 dfeuer joined
15:12 NeverDie joined
15:12 <merijn> dolio: Relevant functions/API is here: https://github.com/merijn/criterion/blob/3aa421e81620739ea6e65650a92efbbc1f2fae69/Criterion/Types.hs#L456-L561
15:13 <merijn> dolio: I'm going to the gym now, so if you have comments, dump them in the PR/issues I opened
15:13 <dolio> Okay, well, I'm at work now, so I probably won't get to it for a while.
15:13 <merijn> s'okay :)
15:14 Gentilhomme joined
15:14 TonL joined
15:14 wroathe joined
15:16 jer1 joined
15:16 <mniip> mivael, weird
15:16 <mniip> I just wrote a lines which is 10x faster than the stock one
15:17 eacameron joined
15:17 <ski> iqubic : something like `pow :: Integer -> <Integer -> Integer>; pow exponent = <\base -> {let loop 0 _ = <1>; loop e0 b0 = <let b1 = {b0} * {b0} in {if r == 0 then loop e1 <b1> else <b0 * {loop e1 <b1>}>}> where (e1,r) = e0 `divMod` 2 in loop exponent <base>}>'
15:18 <mniip> how did that happen
15:19 <ski> iqubic : an application `pow 11' will evaluate to (with some cosmetic variable renaming) the code snippet `<\b0 -> let b1 = b0 * b0 in b0 * let b2 = b1 * b1 in b1 * let b3 = b2 * b2 in let b4 = b3 * b3 in b3 * 1>'
15:19 <mivael> mniip, what do you mean by "the stock one"?
15:20 TonL joined
15:20 <mniip> Data.List.lines
15:20 urodna joined
15:21 <mivael> You mean that the cause of slowness of the "slow" (514 ms) version is probably in 'lines' slowness?
15:21 osa1 joined
15:21 cschneid_ joined
15:21 litchblade joined
15:22 vektorweg1 joined
15:22 DocWinter joined
15:23 <mniip> I'm investicating
15:23 DragonWolf joined
15:24 eklavya joined
15:24 newhoggy joined
15:24 trism joined
15:25 nscott76 joined
15:26 raichoo joined
15:26 hc_ joined
15:27 Rodya_ joined
15:29 <mivael> Can you share you fast 'lines' version so that I could try it locally as well?
15:30 phaji joined
15:30 <mniip> ok
15:30 <mniip> it's only 3x as fast
15:30 <mniip> right now getContents seems to be the bottleneck
15:31 <lpaste> mniip pasted “lines” at http://lpaste.net/354954
15:34 skeet70 joined
15:36 uglyfigurine joined
15:37 jer1 joined
15:39 sssilver joined
15:39 fotonzade joined
15:42 NeverDie joined
15:43 <Squarism> is there some way to get threadid/label printed on errors that usually have the format :<executable-name> : <error-message> ?
15:43 bubinomab joined
15:44 mandolin joined
15:44 NeverDie joined
15:44 newhoggy joined
15:45 <Squarism> <executable-name> : <error-message>
15:45 zero_byte joined
15:46 wroathe joined
15:46 markus_ joined
15:47 <bartavelle> is there a trick to get a string representation of the type of an expression?
15:47 <bartavelle> humm
15:47 <bartavelle> yes there is!
15:47 <geekosaur> TypeRep has a Show instance
15:48 <bartavelle> hah, that might be nicer
15:48 bodisiw joined
15:48 Haskell joined
15:49 <mniip> mivael, ^ if you didn't see
15:49 <Haskell> Need help with this script...
15:49 <sm> Squarism: error' = (unsafePerformIO getProgName ++) ?
15:49 beanbagula joined
15:50 <mivael> mniip, thanks. Experimenting with it.
15:50 <sm> error' = ((unsafePerformIO getProgName ++ ": ") ++)
15:50 justin1 joined
15:50 <Squarism> sm, where is error defined? In Prelude?
15:50 Hamlet joined
15:51 <Hamlet> http://lpaste.net/354950
15:51 cretiq joined
15:53 mandolin joined
15:54 <Hamlet> Need help with this script...
15:54 <Hamlet> http://lpaste.net/354950
15:55 xall joined
15:55 NeverDie joined
15:55 twanvl joined
15:55 <Hamlet> Need help with this script. http://lpaste.net/354950
15:55 alx741 joined
15:55 <pavonia> Hamlet: What is the problem with this?
15:56 pwnz0r joined
15:56 <Hamlet> It doesn't compile
15:56 alx741 joined
15:56 <geekosaur> including full error messages is helpful
15:56 <pavonia> Add the full error message to the paste
15:56 <geekosaur> since various of us run different versions of ghc and the errors do change
15:56 yellowj joined
15:56 <geekosaur> oh
15:57 <ski> <ski> Hamlet : still redundant brackets, on lines `11',`21',`25',`31'. if you indent the `if' on line `31' (and following lines belonging to it) more, then you can omit the curly brackets there. also remove `largestPrimeFactor = ' from both branches. you already have a `let largestPrimeFactor = ' on line `30' that will receive the value of the whole `if'-expression
15:57 <sm> Squarism: http://hoogle.haskell.org/?hoogle=error&scope=set%3Astackage
15:57 <geekosaur> then let largestPrimeFactor = n
15:57 <ski> Hamlet ^
15:57 <geekosaur> that does not work
15:57 jer1 joined
15:57 <ski> Hamlet : i see you did the last of those suggestions
15:57 tobiasBora joined
15:58 <ski> Hamlet : what's the point of `largestPrimeFactor' in the definition of `findLargestPrimeFactor' ? (hint, it has nothing, per se, to do with largestPrimeFactor' inside `main')
15:59 markus_ left
15:59 <Squarism> sm, not sure how i would be able to redfine "error" - if that is what you meant?
16:00 <geekosaur> they defined error' not error
16:00 <Hamlet> This is self-commented code to make it more meaningful. Also, largestPrimeFactor' is used in main, while the first one is used in defn of findLargestPrimeFactor (i.e. general good programming practice I think)
16:00 ckubrak joined
16:00 <ski> <ski> <ski> Hamlet : in the definition of `findLargestPrimeFactor', ...
16:00 <ski> <ski> Hamlet : here again, you have the `then' branch consisting of a `let' (without an `in'), but this time no such thing in the `else' branch. instead you have a further `let' command after the whole `if'-`then'-`else'. it's not clear what you intended here, elaborate ?
16:00 <ski> <ski> Hamlet : one further problem i can see is that your definition of `findLargestPrimeFactor' accepts a list of numbers, but in `main', you're calling `findLargestPrimeFactor' with a single number, not a list
16:00 flatmap13 joined
16:00 newhoggy joined
16:01 <ski> <ski> Hamlet : oh, it also looks like `main' expects that `findLargestPrimeFactor' will return a number (judging from you naming the result `largestPrimeFactor' in `main'), but in the first defining equation of `largestPrimeFactor', you're returning a list (specifically, the empty list)
16:01 <ski> <ski> (it's not clear what you intended to return in the second defining equation of `largestPrimeFactor' ..)
16:01 <ski> .. i don't think you have responded to those points, yet
16:01 flatmap13 joined
16:01 <ski> Hamlet : "while the first one is used in defn of findLargestPrimeFactor (i.e. general good programming practice I think)" -- no, you attempt to *define* (not use) it in there. you don't use it anywhere
16:02 wroathe joined
16:02 <Hamlet> can you correct all the mistakes and post as a new file..? I will then study the differences
16:02 <ski> i possibly could, but i won't
16:02 mandolin joined
16:02 <ski> part of the point is that you should learn to understand the problems you're running into, so that you can handle, and preferable avoid, them yourself
16:03 Elhamer joined
16:03 <ski> in some of the cases here, it's unclear to me what you even tried to achieve. so there i can't really correct your mistake
16:03 <Hamlet> What do I do? In steps, thank you...
16:03 Sonolin joined
16:03 meandi joined
16:03 <mivael> mniip, I did not notice time changes on my environment (neither faster, nor slower, around 570...670 miliseconds). Compilation/runtime options and the source code are here: http://codepad.org/l4p4gKgH http://codepad.org/HO7ACVyD
16:04 <mniip> mivael, tried replacing cat with a file redirect?
16:04 <ski> Hamlet : i'd like you to respond to the messages of mine above which i copied over from a while back ..
16:05 <Hamlet> which one?
16:05 <davean> Hamlet: clearly all of them
16:05 <davean> Hamlet: he took the time to repeat them
16:05 <ski> specifically, "it's not clear what you intended here, elaborate ?"
16:05 dzdcnfzd joined
16:05 <mniip> mivael, also, well, I don't know
16:05 <Hamlet> line #?
16:05 <mniip> I would debug the IO performance separately from the computations
16:05 crobbins joined
16:06 <ski> Hamlet : oh, sorry, i just realized you did fix the second problem there, the number vs. list of numbers one. but there's still one small lingering problem related to that. in `main' you pass `findLargestPrimeFactor' two arguments, but the definition of it clearly expects only one argument before returning a number
16:07 <ski> Hamlet : so after you fix that, there's still the `let' in the `then' branch in the definition of `findLargestPrimeFactor' to keep track of .. also the base case returning an empty list
16:07 <Hamlet> ...I meant to use a composition
16:07 <mivael> mniip, tried redirection (time ./hs.exec +RTS -K16777216 < 10pow5shuffled.in.txt)... no changes, unsurprisingly
16:08 sw1nn joined
16:08 <mivael> mniip, I just wanted to compare to my previous results, which I profiled earlier
16:08 <ski> Hamlet : oh, like `(reverse . listOfFactors) myGivenNumber' ? you'll still need an extra pair of brackets there, in order to not pass two arguments to `findLargestPrimeFactor'
16:08 <Hamlet> yes, I think
16:09 <ski> .. however, you could just as well pass `reverse (listOfFactors myGivenNumber)' as an argument
16:09 quobo joined
16:09 <mivael> mniip, they were with te same calculations... Also, 'main' 'individual time' is 85-95 per cent from all the other.
16:09 <mivael> s/te/the/
16:09 <Hamlet> yes
16:09 <Hamlet> reverse (listOfFactors myGivenNumber)
16:09 crobbins joined
16:10 <ski> if you prefer the composition here, perhaps for the exercise of using it, then go ahead
16:10 <mivael> s/from all the other/comparing to the whole run time/
16:11 <Hamlet> how?
16:11 <ski> (reverse . listOfFactors) myGivenNumber
16:11 <ski> is equal to
16:11 <ski> reverse (listOfFactors myGivenNumber)
16:11 bennofs joined
16:11 newhoggy joined
16:12 orhan89 joined
16:12 meandi_2 joined
16:14 <mivael> ...and equal to: reverse . listOfFactors $ myGivenNumber
16:14 <mivael> ;)
16:14 sssilver joined
16:14 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
16:15 <ski> mivael : yea, but i don't suggest that, since i think using `$' much is ugly ;)
16:15 besenwesen joined
16:15 danthemyth joined
16:15 <ski> Hamlet : to summarize, the remaining things i see are (a) `main' expects `findLargestPrimeFactor' to return a number, but the base case returns an empty list; (b) the recursive case of `findLargestPrimeFactor' is confused, specifically the `then' branch; (c) the call to `findLargestPrimeFactor' in `main' being passed two arguments (we just talked about that); ..
16:16 <ski> Hamlet : .. and (d) (style) redundant (round) brackets on lines `11',`21',`25',`31', and redundant curly brackets on `30'-`33', which you can avoid by indenting the `if'-expression more
16:16 <ski> Hamlet : you're still missing an extra (required) pair of brackets on line `33'
16:17 teggi joined
16:17 <ski> Hamlet : `findLargestPrimeFactor reverse (...)' is passing `reverse' as one argument to `findLargestPrimeFactor', and `...' as another argument. if you want to apply `reverse' to `...', then you must wrap that application in brackets, in order to pass the result thereof to `findLargestPrimeFactor' as an argument
16:17 <mivael> ski, I like it for some reason :) maybe it reminds me '|' of unix command line which I use extensively, just in reverse direction
16:17 wroathe joined
16:18 <ski> Hamlet : .. and with that, i must leave now. good luck. perhaps someone else can carry on here ..
16:18 <Hamlet> thnx
16:19 crobbins joined
16:20 crobbins joined
16:20 iAmerikan joined
16:21 jer1 joined
16:21 moet joined
16:22 newhoggy joined
16:22 Rodya_ joined
16:23 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
16:24 <Jaxan> My stack installation uses 3gb of space (in ~/.stack), is there a way to trim it down a bit?
16:24 cpennington joined
16:24 jluttine joined
16:25 sssilver joined
16:25 cdg joined
16:26 <Jaxan> I guess it's safe to just delete that whole dir, isn't it?
16:26 markasoftware_ joined
16:26 jchia joined
16:27 harfangk joined
16:27 mthek joined
16:27 newhoggy joined
16:27 cfricke joined
16:28 jmelesky joined
16:29 <phadej> Jaxan: it is safe; but it will grow to that size quite quickly again
16:29 <Jaxan> It's really annoying, since I'm working in a VM with just 8GB of disk
16:29 <phadej> (IIRC 2GB sandboxes were quite common, so 3.3GB isn't that much)
16:29 Aruro joined
16:29 seveg joined
16:30 roconnor joined
16:30 vargeek joined
16:31 ChaiTRex joined
16:32 <phadej> Jaxan: try ls ~/.stack/snapshots/x86_64-linux | while read s; do du -hs ~/.stack/snapshots/x86_64-linux/$s; done
16:32 f1b3r joined
16:32 <phadej> it'll show how space is used by packages from different snapshots (so you can try to optimise)
16:32 mizu_no_oto_work joined
16:33 <phadej> note: it's not safe to remove single snapshot
16:33 f1b3r left
16:33 willprice94 joined
16:33 <phadej> e.g. I have 1,4G .stack/snapshots/x86_64-linux/nightly-2017-04-01
16:34 vimto joined
16:34 wroathe joined
16:35 newhoggy joined
16:36 sssilver joined
16:36 <davean> Jaxan: frankly, any modern toolset will probably be in that size range, I know of single C++ libraries that can install to that large
16:36 vargeek_ joined
16:36 <davean> Jaxan: I know thats not that nicest answer but ...
16:38 <Jaxan> Maybe 8GB for my VM was a bit optimistic ;D
16:38 <davean> I think it was.
16:39 <Jaxan> pacman is alsop using a cache of 3GB -.-
16:39 <na_th_an> pacman -Sc (or -Scc)
16:39 <na_th_an> to clean the cache
16:39 <davean> You probably don't require a whole bunch more space, but you're really causing yourself more issues then its probably worth to not add a few GBs
16:40 <davean> any improvements in size are going to come at a massive increase in CPU time or a massive restriction in what you can use
16:40 <davean> And these options *do* exist, but they're not easy
16:40 jer1 joined
16:41 mthek joined
16:41 ilyaigpetrov joined
16:41 splanch joined
16:41 APrOn joined
16:41 Cogitabundus joined
16:41 vargeek_ joined
16:41 <Hamlet> Need help with this script...
16:41 vargeek_ joined
16:41 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
16:42 eazar001 joined
16:43 StoneToad joined
16:43 teggi joined
16:43 cables joined
16:44 sproingie joined
16:44 <mniip> Hamlet, what ski said
16:44 <mniip> no one is going to do your homework
16:44 <mniip> read the advice you've been given and try fixing the mistakes yourself
16:44 vargeek joined
16:45 <Hamlet> I did the steps (except the brackets ones which I kept), and some refactoring
16:45 mmachenry joined
16:45 RegEchse joined
16:45 JKD joined
16:46 <mniip> you're applying 'take' wrong
16:46 <Jaxan> phadej, davean and na_th_an: thanks, I will find a way to manage ;D
16:46 crobbins joined
16:46 <mniip> you're applying take to 1 then to findLargestPrimeFactor and then to (reverse ...)
16:46 <mniip> it should be
16:46 <mniip> take 1 (findLargestPrimeFactor (reverse ...))
16:47 crobbins joined
16:47 newhoggy joined
16:47 <dzdcnfzd> is there a canonical function which does fmap lift?
16:47 <dzdcnfzd> :t fmap lift
16:47 <lambdabot> (Functor f, Monad m, MonadTrans t) => f (m a) -> f (t m a)
16:48 crobbins joined
16:48 <mniip> dzdcnfzd, are you sure that's what you want?
16:48 <mniip> you have a functor of transformers?
16:49 <dzdcnfzd> mniip: I'll give you the context
16:49 <mniip> Hamlet, next, I'm not sure what you want the findLargestPrimeFactor function to return
16:49 wroathe joined
16:49 <mniip> is it a number or Maybe number?
16:49 baweaver left
16:50 crave joined
16:50 <dzdcnfzd> mniip: http://lpaste.net/198162261959770112
16:50 tommd joined
16:51 <dzdcnfzd> mniip: You can see that postBlog' is an attempt to do postBlog without do notation
16:51 <dzdcnfzd> I'm trying to do that as simply as possible, and I think it's likely I'm screwing up
16:51 Cogitabundus joined
16:51 <mniip> you don't want to use fmap here
16:51 <mniip> ahhhh
16:51 <mniip> it's fmap for the function type
16:52 <mniip> just use .
16:52 <mniip> lift . (flip modifyTVar ...)
16:52 <mivael> mniip, I tried that without calculations (except for summing up the input numbers). Environment and options are the same. The run time seems to be statistically smaller with your 'lines' version (390+ miliseconds) comparing to Prelude.lines (430+ miliseconds). http://codepad.org/lerwSm8h
16:53 connrs joined
16:54 aarvar joined
16:54 aarvar left
16:56 <mivael> phadej, Jaxan, maybe something like this also can be useful: du -kxa -- ~/.stack/snapshots/x86_64-linux | sort -nr | head -100
16:56 mohsen_ joined
16:56 binaryplease joined
16:57 <mivael> (top of candidate directories for optimization)
16:57 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
16:57 sleffy joined
16:58 mmn80 joined
16:59 <Hamlet> ... gives complicated & confusing error message...
16:59 <mniip> Hamlet, what does 'findLargestPrimeFactor' do?
16:59 <mivael> s/directories/directories and files/
17:01 conal joined
17:01 codesoup joined
17:01 <Hamlet> it returns the first prime number in a list of ordered [largest to smallest] factors of a number
17:01 jer1 joined
17:01 jrm joined
17:03 leat joined
17:03 danza joined
17:03 Elhamer joined
17:04 splanch joined
17:05 wroathe joined
17:06 raynold joined
17:06 cdg_ joined
17:06 splanch_ joined
17:06 <monochrom> findLargestPrimeFactor (reverse (listOfFactors myGivenNumber))
17:06 <mniip> Hamlet, then why do you return Nothing
17:06 <mniip> and
17:06 <mniip> why do you check for primality
17:07 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
17:08 splanch__ joined
17:08 conal joined
17:09 mbuf joined
17:09 newhoggy joined
17:09 <Hamlet> Problem sol'n strategy: First, take the listOfFactors of myGivenNumber; Second, reverse the list to give largest -> smallest factors; Third, check each factor until first prime factor is found.. that is largestPrimeFactor
17:11 nesqi joined
17:11 sam___ joined
17:12 t7 joined
17:13 cdg joined
17:14 sam___ left
17:16 doomlord joined
17:16 acertain joined
17:18 cpennington joined
17:21 wroathe joined
17:21 biglambda joined
17:21 mmalone joined
17:22 orhan89 joined
17:22 jer1 joined
17:23 <mniip> what if none are found
17:23 modal joined
17:24 newhoggy joined
17:24 arctictern joined
17:24 insitu joined
17:25 <Hamlet> Q: How do you take a value from a list? e.g. I want the value of the singleton list [5]
17:25 tusj joined
17:25 <EvanR> > (\[x] -> x) [5]
17:25 <lambdabot> 5
17:25 <EvanR> > (\[x] -> x) []
17:25 <lambdabot> *Exception: <interactive>:3:2-10: Non-exhaustive patterns in lambda
17:26 <EvanR> (\[x] -> x) also known as head, requires you to know that the list isnt empty. or else kablooey
17:27 <EvanR> in general you cant have any value from a list, it might be empty
17:27 <mizu_no_oto_work> There's also safeHead
17:27 <mizu_no_oto_work> thttps://hackage.haskell.org/package/safe
17:27 <EvanR> which leads to asking how you get the value from a Maybe
17:28 nbro joined
17:28 nbro left
17:28 <mizu_no_oto_work> :t maybe
17:28 <lambdabot> b -> (a -> b) -> Maybe a -> b
17:28 <EvanR> with safeFromJust!
17:28 <Hamlet> "what if none are found" - Any number is composite or prime, ie. there is a minimum prime number factor for any given (composite) number
17:28 <MonadHendrix> :t catMaybes
17:28 <lambdabot> [Maybe a] -> [a]
17:28 <EvanR> you probably want to do some strategy like maybe directly on that list anyway
17:28 <ExpHP> am I right in thinking that 'let m' = (m >>= (pure $!)) in m' >>= f" will reliably force m's contents before they are passed into f?
17:28 <Lokathor> hmm, libraries that provide typeclasses should provide more quickcheck properties about those typeclasses :P
17:29 <ExpHP> (since it hides the data constructor for the monad behind $!)
17:29 <Hamlet> Q: How do you take a value from a list? e.g. I want the value of the singleton list [5]
17:29 <Tuplanolla> You should define an F-algebra `headAlg` and then use `extract . cata headAlg`, Hamlet.
17:30 <kadoban> Hamlet: Pattern match, or if you know it's exactly that, you could use the 'head' function, though it'll crash if you're wrong.
17:30 <Lokathor> Hamlet, usually "head", or a pattern match, or !!
17:30 <Lokathor> what kadoban said :3
17:30 <* EvanR> waits for the question to be repeated
17:30 <kadoban> Well you added !! which I forgot about xD
17:31 richi235 joined
17:31 <mizu_no_oto_work> > fromMaybe 0 $ listToMaybe [1,2,3]
17:31 <mizu_no_oto_work> > fromMaybe 0 $ listToMaybe []
17:31 <lambdabot> 1
17:31 <lambdabot> 0
17:31 <mizu_no_oto_work> Hamlet ^
17:32 roconnor joined
17:32 <EvanR> if its impossible for the list to be empty, that wouldnt make much sense
17:32 dm3 joined
17:32 <EvanR> since its the list of prime factors
17:32 <EvanR> ...
17:32 <Tuplanolla> For `1`, EvanR?
17:32 <mizu_no_oto_work> listToMaybe in Data.Maybe is the same as headMay in Safe.
17:33 unK_ joined
17:33 <EvanR> the answer is clear [1]!
17:34 <mizu_no_oto_work> Safe also has "headNote :: String -> [a] -> a ", so you could get the head of the list via `headNote "factorizations must contain prime numbers, so this should never be empty" factors`
17:34 <Tuplanolla> Is this a `listOfUsuallyPrimeFactors`?
17:34 <mizu_no_oto_work> Alternatively, pattern matching works
17:35 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
17:35 <EvanR> it does simplify the question of dealing with empty lists
17:35 <Hamlet> My file above has the code
17:35 ploop joined
17:36 <rblaze> listOfUsuallyPrimeButSometimesNotFactors
17:36 <MonadHendrix> rblaze: lol
17:37 replay joined
17:37 acertain joined
17:37 NeverDie joined
17:37 <reactormonk[m]> For a bit of dependent typing, I can't use typeclasses anymore - how would I make https://gist.github.com/23c639d34302d918a41ba4e555d4dd37 compile?
17:37 <reactormonk[m]> ... which data structure would I need?
17:38 <nitrix> Can GHC optimize the wrapping/unwrapping of Maybe in the examples above?
17:38 BlueRavenGT joined
17:38 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
17:38 dm3 joined
17:40 newhoggy joined
17:40 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
17:41 robatosan joined
17:41 <cocreature> nitrix: which examples are you referring to?
17:41 bvad joined
17:42 Hamlet joined
17:42 malt3 joined
17:42 jer1 joined
17:43 <nitrix> cocreature: \f -> fromMaybe f . listToMaybe
17:43 <Hamlet> http://lpaste.net/354950
17:44 ixxie joined
17:44 hazyPurple joined
17:44 butterthebuddha joined
17:45 <Hamlet> @nminip, this is my script... http://lpaste.net/354950
17:45 <lambdabot> Unknown command, try @list
17:45 Itkovian joined
17:45 cyborg-one joined
17:45 <cocreature> nitrix: yep
17:45 <cocreature> nitrix: you can use -ddump-simpl to see the core ghc produces
17:45 splanch joined
17:46 <cocreature> it takes a while until you get used to reading it but then it’s really useful
17:46 gienah joined
17:46 <cocreature> nitrix: in this case it looks like this http://lpaste.net/354965
17:46 soLucien joined
17:47 <nitrix> cocreature: (@ c_ay5)
17:47 newhoggy joined
17:47 <nitrix> cocreature: There's an implicit type as first agument?!
17:47 <cocreature> yep
17:48 <cocreature> there is in Haskell as well
17:48 <cocreature> and with -XTypeApplications you can specify it :)
17:48 acidjnk22 joined
17:48 <nitrix> I've played with -XTA but I thought it was a trickery of the type inference, not actually part of the implementation.
17:48 tauli joined
17:49 <cocreature> core has had explicit type applications for quite some time, maybe even forever
17:49 biglambda joined
17:49 <Tuplanolla> I'm pretty sure forever.
17:49 <cocreature> probably
17:50 <Hamlet> How do I message someone directly?
17:50 <geekosaur> /msg user stuff
17:50 <geekosaur> note that they can disable this if you are not registered with nickserv
17:50 <nitrix> cocreature: This reads fairly nicely if I squint my eyes. I see that Maybe did get eliminated.
17:51 <ExpHP> or "/query user" usually opens a new tab where you can type stuff on most clients
17:51 <nitrix> cocreature: I wish I could understand the naming convention though.
17:51 <nitrix> s/convention/generation/
17:51 <cocreature> I have no idea how they are chosen :)
17:52 <* nitrix> flips cocreature upside down.
17:52 <cocreature> oO
17:52 <cocreature> what did I do to deserve that
17:52 <thoughtpolice> You can use -dsuppress-uniques to get output far closer to what they originally were, for certain bindings.
17:52 wroathe joined
17:52 <Hamlet> Need help with this script... http://lpaste.net/354950
17:52 <dolio> I think it involves a hash function.
17:53 gcross joined
17:53 <thoughtpolice> Some bindings are simply introduced. Some others, like dictionaries, tend to follow a certain convention already (something like 'fOrdInt' or something IIRC)
17:53 newhoggy joined
17:53 MarioBranco joined
17:54 doomlord joined
17:54 cables joined
17:54 orhan89 joined
17:55 biglambda joined
17:55 <nitrix> thoughtpolice: Good to know for -dsuppress-uniques.
17:56 <nitrix> cocreature: You changed my perspective on the world. I'm just making you look straight again :P
17:56 butterthebuddha joined
17:56 <cocreature> heh :)
17:57 soLucien joined
17:58 takle joined
18:00 xall joined
18:00 buttbutter joined
18:02 ikke joined
18:03 jer1 joined
18:04 sepp2k joined
18:04 baldrick joined
18:05 newhoggy joined
18:06 unyu joined
18:07 ixxie joined
18:07 zv joined
18:07 mmachenry1 joined
18:08 cdg joined
18:09 crobbins joined
18:09 phyrex1an joined
18:11 zeroed joined
18:12 connrs joined
18:12 jchia_1 joined
18:13 <Lokathor> *go to the project's repo to report a bug in the windows build*
18:13 <Lokathor> *they already have the fix posted*
18:13 <Lokathor> :D
18:15 meoblast001 joined
18:16 fosskers joined
18:16 tomboy64 joined
18:17 lavalike joined
18:18 iomonad joined
18:18 sboosali joined
18:18 tommd joined
18:19 newhoggy joined
18:21 flatmap13 joined
18:23 asmyers joined
18:24 jer1 joined
18:24 wroathe joined
18:28 kritzcreek joined
18:32 mac10688 joined
18:35 yellowj joined
18:35 Discovery joined
18:36 balor joined
18:38 cdg_ joined
18:38 newhoggy joined
18:39 cpennington joined
18:39 prkc joined
18:39 theelous3 joined
18:39 cretiq joined
18:40 wroathe joined
18:40 soniku joined
18:41 <MonadHendrix> anyone got some good code to read
18:41 richi235 joined
18:42 garlvinland joined
18:42 <shapr> MonadHendrix: have you seen hedgehog?
18:42 ohsix joined
18:43 <MonadHendrix> i haven't
18:43 <garlvinland> hi, can I direct any summer of haskell 2017 questions here or is there a dedicated channel?
18:43 <shapr> I think there's a dedicated channel, but I forget the name
18:43 <MonadHendrix> https://github.com/hedgehogqa/haskell-hedgehog this?
18:43 <shapr> MonadHendrix: yeah!
18:43 <MonadHendrix> shapr: thanks, will take a look
18:44 <Zemyla> You know, it occurs to me that, if you have a type f such that, for some Monad m, you don't have (<*>) :: f (a -> b) -> f a -> f b, but you do have (<*=>) :: f (a -> b) -> f a -> m (f b), then you can still make an Applicative from it.
18:44 <MonadHendrix> anything similar to that 'typing the technical interview' is also cool, finished reading all the Monad Readers and am procrastinating at record levels
18:44 jer1 joined
18:45 <MonadHendrix> garlvinland: #haskell-gsoc
18:45 connrs joined
18:45 sproingie joined
18:45 <MonadHendrix> garlvinland: how poroficient do you need to be to enter that, looks cool
18:45 <MonadHendrix> *proficient
18:46 <shapr> MonadHendrix: oh, I like The Monad Reader
18:46 <shapr> Though there's not been a new issue for years
18:46 <monochrom> Zemyla: How do you make an Applicative from it?
18:47 <shapr> I'm tempted to restart TMR
18:47 <MonadHendrix> maybe ill write an article one day
18:47 <monochrom> That's what I said too. 5 years ago.
18:47 <garlvinland> @MonadHendrix thanks. no idea, I've started learning haskell on my own and thought it would be a good incentive to go all-in on the learning experience
18:47 <lambdabot> Unknown command, try @list
18:47 <akr[m]> how does `cabal report` work exactly? It gives me no output in the shell after I input my login information, even with -v3
18:47 <garlvinland> MonadHendrix thanks. no idea, I've started learning haskell on my own and thought it would be a good incentive to go all-in on the learning experience
18:48 <akr[m]> and nothing has changed on the page for the package at hackage
18:48 <Zemyla> monochrom: Well, to start, look at this post I made on Curried Yoneda Applicatives and `confusing` in lens: https://www.reddit.com/r/haskell/comments/5715b3/when_can_i_expect_overhead_for_lens/d8p78os/?context=3
18:48 <shapr> monochrom: did you write an article?
18:48 <monochrom> No.
18:48 <shapr> WHY NOT?
18:48 <shapr> I wrote an article for TMR once
18:49 sssilver joined
18:49 texasmynsted joined
18:49 iomonad joined
18:49 <Zemyla> But you'll want to use a subtly different type: newtype MCurr m f a = MCurr { unMCurr :: forall r. f (a -> r) -> m (f r) }
18:49 <monochrom> Ah no wonder.
18:50 <shapr> Zemyla: want to write an article for The Monad Reader?
18:50 <Zemyla> Oh? How would I do that?
18:51 <shapr> Well, you write an article, and the editor likely accepts it.
18:51 <Zemyla> Though actually, I have an idea on a good example.
18:51 <shapr> ezyang: any word on new TMR issues?
18:51 <shapr> I think ezyang was the most recent person running TMR
18:52 <monochrom> TMR? HWN?
18:52 <shapr> I thought haskell weekly news was something else entirel?
18:52 <shapr> wasn't CosmicRa` running HWN?
18:52 <monochrom> Yes. I think ezyang was doing HWN.
18:53 dm3 joined
18:54 <monochrom> Nevermind. You're right.
18:54 dm3 joined
18:54 laplacian joined
18:54 newhoggy joined
18:55 takle joined
18:55 <monochrom> First order of business is to enter the new age and call it The Applicative Reader. Then you can also get to put the latex code in a tar file.
18:55 texasmynsted joined
18:55 wroathe joined
18:56 oisdk joined
18:58 takle joined
18:58 zeroed joined
19:00 unyu joined
19:00 pie_ joined
19:00 ego joined
19:00 <pie_> so, as type systems get more and more advanced, do we not go from writing programs to writing programs in type systems? isnt that basically just shifting the burden?
19:01 <geekosaur> spreading it, really. a program literally written in the type system would be run by compiling; most programs still run the traditional way, instead of being compiled to run
19:01 <monochrom> No, it is worse (or better). You write the program twice, once at the term level, once at the type level.
19:03 <* pie_> mumbes smething about redundancy i guess
19:03 dm3 joined
19:03 <monochrom> It has the prospect of being better because what Hoare said about "oh but how wonderful would it be if you could get rid of a lot of bug by just writing your code twice!"
19:03 <pie_> you guys know anything that discusses this in a little more depth or is there no point?
19:03 <pie_> monochrom, hehh
19:04 Swizec joined
19:04 <isd> So, the thing is, as you write more in the type system, you also have fewer things you can only check via tests. The redundant code for verification is going to be *somewhere* if you're doing things correctly, but with the type system it will be more exhaustive, if it can capture the checks.
19:04 <monochrom> And indeed he said that to support types, although he only had the monomorphic ones in mind, i.e., in Algol you had to declare "i : int".
19:04 ryxai joined
19:04 <monochrom> But writing specifications as types is his sentence taken to the extreme.
19:05 <isd> Like, I've seen plenty of python unit test that check for trivial type errors.
19:05 jer1 joined
19:05 <monochrom> Redundancy is the basis of error detection.
19:05 <pie_> <isd> Like, I've seen plenty of python unit test that check for trivial type errors.
19:05 <pie_> this is really my main problem with python right now
19:05 <EvanR> the more tests you can write, the more typing you do, the more productive you are, dont question this
19:05 <pie_> otherwise i like it
19:05 <monochrom> And moar redundancy is the basis of error correction.
19:06 <isd> In my experience, when you can verify with the types instead of tests, it's more concise *and* more exhaustive.
19:06 <pie_> monochrom, quantity over quality right? ;PPPP
19:06 <EvanR> yes but writing the program twice in a row is almost the worst way to add redundancy
19:06 doomlord joined
19:06 <EvanR> only surpassed by writing it 3x in a row
19:06 <pie_> but thats not even wrong because types hopefully cover the entire space of the thing
19:06 <monochrom> No, it is more about working on two perspectives.
19:06 <pie_> yeah thats what i figured
19:07 <monochrom> You usually use one mindset to write the spec, another mindset to write the code. The two perspectives together form a very good cross-check.
19:08 oish joined
19:08 <EvanR> RMS said that computer science is the easiest of all sciences, each programming piece has no change of messing up, breaking, overheating, getting EMI, etc because its mathematically simple. and you "just" have to then worry about the complexity of putting the pieces together
19:08 <EvanR> he was almost certainly talking about lisp programming
19:08 <EvanR> or C
19:08 <monochrom> Test-driven programming is based on the same philosophy, except that people don't realize that tests are small specifications.
19:09 <EvanR> tests are error prone specifications
19:09 <EvanR> usually
19:09 <Tuplanolla> Not C, EvanR. I'm working on a project where changing include order affects program behavior right now.
19:09 <monochrom> No.
19:09 <isd> He was talking about the fact that code doesn't "go bad" -- not that you can't have errors, but you don't have programs beginning to fail as a direct result of being old.
19:10 <EvanR> but you cant deny that the include mechanism is so simple it hurts (when you put many includes together)
19:10 <monochrom> Electronic computers are messed up by overheating and EMI all the time.
19:10 <Zemyla> shapr: So how and where do I submit an article for The Monad Reader?
19:10 newhoggy joined
19:10 <EvanR> anyway as easy as it all seems, its amazing how adding the more and more sophisticated type system makes it even easier
19:11 <monochrom> OTOH if you do it Dijkstra's way, programming by pen and paper, then you are immune to EMI, but you may still overheat your pen tip :)
19:12 <EvanR> i do most haskell on pen and paper
19:12 wroathe joined
19:12 Rodya_ joined
19:12 <EvanR> because i dont usually make it to the point where typing it in would make any sense
19:13 <EvanR> so productivity per line of code is skyrocketing
19:16 <pie_> https://www.youtube.com/watch?v=ZKmodCApZwk category theory, type theory or proof theory in what order? wat do?
19:16 fakenerd joined
19:16 <pie_> monochrom, heh :)
19:17 roconnor joined
19:17 <pie_> or in other words: i dont know types, wat do
19:17 <* pie_> is aiming for idris
19:17 <cocreature> if you’re aiming for idris, read edwin’s book :)
19:17 <Tuplanolla> I'd leave categories last simply because all the examples are from other fields, pie_.
19:17 <pie_> cocreature, i have a copy :D but id still like to understand types
19:18 <pie_> cocreature, not to criticize edwins pedagogy xD thats not what i meant
19:18 <mniip> 1493233554 [22:05:54] <monochrom> And moar redundancy is the basis of error correction.
19:18 <mniip> no
19:18 quobo joined
19:18 <pie_> more like its probably going to take me a lot of the idris book to get a little bit of type theory. then again learning TT mathematically might be unpractical :P
19:18 newhoggy joined
19:18 <mniip> the basis of error correction is non-intersecting spheres
19:18 <EvanR> look at the first chapter of the HoTT book
19:19 danthemyth joined
19:19 ner0x652 joined
19:20 <pie_> EvanR, ok \o/
19:21 <cocreature> harper’s book is also pretty good although I have to admit I never finished it due to a lack of time & interest :)
19:21 <monochrom> Yes the first chapter is good for type theory. If you don't need the "Ho" part you can simply stop after the first chapter.
19:21 asmyers joined
19:21 <Zemyla> So the last issue of the Monad Reader seems to have been published in 2015?
19:22 ozgura joined
19:22 <Zemyla> Unless there's another one out there?
19:22 newhoggy_ joined
19:22 <cocreature> Zemyla: sounds about right. it’s been dead for some time
19:22 <monochrom> mniip, non-intersecting spheres means how to use the redundancy most meaningfully, rather than meaning irredundancy.
19:23 <Zemyla> So someone suggested I write up a technique I found and submit it to it. Is there another good place for me to submit it where people can read it and I don't need to have a blog of my own?
19:23 <EvanR> github repo maybe
19:25 peterbecich joined
19:25 jer1 joined
19:26 <zomg> Zemyla: medium? :P though you should start a blog if you like to write :)
19:27 <Tuplanolla> Some sort of community blog, Zemyla?
19:27 sellout- joined
19:27 wroathe joined
19:27 <monochrom> reddit
19:27 <Tuplanolla> If you don't mind being drowned in a sea of garbage, monochrom.
19:28 <monochrom> Create two accounts on stackoverflow. Use one account to ask a fake question, whose solution is your article. Use another account to post the solution, which is your article. :)
19:28 <monochrom> Post on facebook.
19:28 JoshS joined
19:29 <monochrom> Make a video of scrolling through your article slowly. Post the video on Youtube. :)
19:29 <monochrom> Post on comp.lang.haskell
19:29 Itkovian joined
19:29 mlehmk joined
19:29 <monochrom> (Does anyone want to ask "what is comp.lang.haskell?"? :) )
19:31 <monochrom> Post on haskell-cafe
19:31 filostrato joined
19:31 augur joined
19:33 jeltsch joined
19:34 filostrato joined
19:34 newhoggy joined
19:34 adraenwan joined
19:35 buttbutt1r joined
19:35 msks joined
19:36 buttbutt2r joined
19:37 beanbagula joined
19:38 <Ankhers> monochrom: You can answer your own questions on SO. It is even encouraged. They have a checkbox when you are asking your question to let you answer it immediately before it is even posted. As for comp.lang.haskell, that sounds like a usenet group. Haven't actually looked though.
19:39 conal joined
19:40 filostrato joined
19:40 <monochrom> Ah that's better than two accounts :)
19:41 Durbley joined
19:41 dm3 joined
19:41 pera joined
19:43 Hamlet joined
19:43 alx741 joined
19:43 <Hamlet> Need help with this program.. http://lpaste.net/354950
19:44 leothrix joined
19:44 <monochrom> Hamlet, I am not sure how a comment causes a type error.
19:44 <pie_> monochrom, the wrong question to ask is will this help me? http://www.cse.chalmers.se/research/group/logic/book/book.pdf
19:45 <pie_> im already not really getting the whole judgement/proposition thing
19:45 Oejet joined
19:45 tv joined
19:46 gawen joined
19:46 fizbin joined
19:46 filostrato joined
19:46 <MonadHendrix> monochrom: stick a $ after findLargestPrimeFactor in the second let statement of main
19:46 jer1 joined
19:46 Deide joined
19:47 <monochrom> pie_, I agree with you, I didn't understand the distinction until two years after I aced a logic course that was supposed to insist on the distinction. :)
19:47 <MonadHendrix> uh
19:47 <MonadHendrix> Hamlet: ^
19:47 niez joined
19:47 augur joined
19:47 <pie_> heh
19:47 <pie_> ok
19:48 <pie_> i mean i think i have a vague inkling
19:48 <pie_> moar meta
19:48 <MonadHendrix> `findLargestPrimeFactor reverse_listOfFactors myGivenNumber` is doing ((findLargestPrimeFactor reverse_listOfFactors) myGivenNumber)
19:48 <monochrom> But it may help to say the two things are on two different levels, judgment is at the meta level, proposition is at the target level. There are other points too.
19:48 <MonadHendrix> not (findLargestPrimeFactor (reverse_listOfFactors myGivenNumber))
19:48 newhoggy joined
19:48 <pie_> the problem is i dont really get the meta in this case :P
19:48 <pie_> well, we'll see how it goes
19:48 danza joined
19:49 <pie_> i mean i see that its meta, i just dont know that that actually means
19:49 <MonadHendrix> i hope your terminal is wide enough for that to be clear
19:49 <MonadHendrix> because mine isn't
19:50 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
19:50 <monochrom> OK, I'll try an analogy, I don't know how well it works and how much it breaks. Compile-time computations are like meta level. Run-time computations are like target level.
19:50 Durbley joined
19:50 <pie_> monochrom, if i havent learned any topology proper yet, is HoTT not for me?
19:51 filostrato joined
19:51 <pie_> man theres so many areas of math i wish i had better grounding in
19:51 <monochrom> If you haven't seen topology, only the "Ho" part is not for you.
19:51 <pie_> ok
19:51 <monochrom> HoTT's chapter 1 is really vanilla Martin-Löf, no Ho.
19:52 <pie_> does the fact that this has topology give some kind of geometric meaning to programs?
19:52 <pie_> (topology just makes me think geometry, is that a bad trigger?)
19:52 <monochrom> I don't know.
19:52 cdg joined
19:52 <monochrom> Yes.
19:52 <pie_> ok
19:52 <pie_> i mean i know its not the same as geometry
19:53 <Hamlet> Updated file.. still errors http://lpaste.net/354950
19:53 <monochrom> Geometry cares about distance, in fact look at the "metry" suffix, it's all about distance. Topology ignores distance.
19:53 <Tuplanolla> Having studied general topology first, it didn't help me understand homotopy type theory at all, pie_.
19:53 <pie_> "Topology is the field concerned with the properties of geometric objects that are unchanged by continuous mappings. In practice, this often means dealing with large-scale properties of spaces, such as connectedness and compactness." huh.
19:53 <pie_> Tuplanolla, ok
19:54 bperez joined
19:54 <pie_> monochrom, felix kleins imagining of geometry is actually all about groups \o/ (iirc)
19:54 filostrato joined
19:55 <pie_> anyway, geometry is cool (tm)
19:55 <monochrom> I have a tea cup with a handle in front of me. If I say "this is equivalent to a donut" it may sound odd. It is false for geometry, the distances (rather, ratios between distances) don't match up. But it is true in topology, there is a continuous bijection, whose inverse is continuous too, between my cup and the donut.
19:55 asakeron joined
19:55 <bperez> Looking for some help with ghc plugins. Every time I use -fplugin I get an error telling me the plugin module imports itself, even though that's not the case. I've even tried this with the example plugin on the ghc wiki
19:55 <pie_> i wish my cup was a fonut :(
19:55 chaosmasttter joined
19:55 <Hamlet> By the way, I'm perusing this.. http://www.open.ou.nl/bhr/heeren-helium.pdf | Not sure if Helium is helpful for beginners.. any feedback from anyone here?
19:55 <pie_> im having sugar cravings. probably addicted to sugar.
19:56 refold joined
19:56 <pie_> i really miss me some american donuts...
19:56 <monochrom> And I keep forgetting what homotopy focuses on.
19:56 <pie_> well homo means same and topos means plave
19:56 <pie_> place
19:56 newhoggy joined
19:56 <pie_> so i have no idea :P
19:57 meiji11 joined
19:57 <Tuplanolla> I also don't understand why people always mention embeddings when they want to explain topology. It looked more like set theory on steroids to me.
19:57 <pie_> Tuplanolla, that sounds plausible
19:57 <meiji11> I'm generating Haskell code using Template Haskell, and the code it pretty prints generates parse errors on ghc 8.0.1. is there any way I can rectify that? I had similar problems with GHC 7.8.2 and I had to roll back to 7.6.2.
19:57 cloudhead joined
19:58 <monochrom> Mathematicians tend to present everything as sets on steroids. Recall that vector spaces are glorified sets too.
19:58 <monochrom> Well, even a 2-tuple is a glorified set.
19:58 <Sornaensis> > (1,"blorps")
19:58 <lambdabot> (1,"blorps")
19:58 sgflt joined
19:58 wroathe joined
19:59 <cloudhead> hey, does anyone know how I can use digestive-functors to parse a form with dynamically generated inputs with the same 'name' field?
19:59 <monochrom> They have a highly set-manipulating proof for fst(x,y) = x.
19:59 <sampuka> :t (,,,,,,,,,,,,,,)
19:59 <lambdabot> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
19:59 <cloudhead> I've been struggling to find a way
20:00 <Sornaensis> :t (,) . (,)
20:00 <lambdabot> a -> b1 -> (b -> (a, b), b1)
20:00 <monochrom> You will probably enjoy the book "Topology via Logic" which gets rid of sets.
20:00 <monochrom> It's also fairly cheap and thin.
20:00 iAmerikan joined
20:00 ExpHP joined
20:01 <Tuplanolla> Topology could have been presented in a pointless manner, but no, the books had to do their earnest to make it as boring and unpleasant as real analysis.
20:01 <monochrom> But IMO embedding is a good idea.
20:01 <Tuplanolla> My bias may be showing a little here.
20:01 <ystael> Tuplanolla: point set topology divides into two parts: boring technical nonsense to implement real analysis, and boring technical nonsense to implement homotopy theory. :)
20:02 <monochrom> I have a tea cup in front of my, and I still think that the best way to visualize it is to embed it in the 3D space I live in, rather than me shrinking down to an ant to walk on its surface 2Dly.
20:02 dsh joined
20:03 <Hamlet> Q: Has anyone used Helium here?
20:03 <monochrom> Err actually both perspectives are valuable. You certainly want to do both, sooner or later.
20:03 filostrato joined
20:03 <monochrom> So, please don't hate embedding, even though you can hate sets as much as you want, I'm in agreement there :)
20:04 <monochrom> haha ystael
20:04 nicknovi1 joined
20:06 merijn joined
20:06 <pie_> monochrom, well, something somthing foundations of mathematics so...yknow
20:07 jer1 joined
20:07 torstein joined
20:08 newhoggy joined
20:09 <* pie_> wished continuous meant differentiable
20:09 moet joined
20:11 <shapr> Zemyla: as far as I can tell, ezyang is the current TMR leader, but I'll see if they're bored with it.
20:11 <shapr> if the answer is yes, then I can be the next TMR editor/leader! w00t!
20:12 dzdcnfzd joined
20:12 ExpHP joined
20:14 <dzdcnfzd> Anybody have any ideas? Stuck on figuring out how to make the right natural transformation for my Servant Server: http://lpaste.net/5053080047955476480
20:14 wroathe joined
20:15 <merijn> dzdcnfzd: What's :~> ?
20:15 <dzdcnfzd> (see lines 57 - 71)
20:15 <dzdcnfzd> merijn: it's from https://hackage.haskell.org/package/servant-0.10/docs/Servant-Utils-Enter.html#t::-126--62-
20:16 <merijn> dzdcnfzd: Also, rather than using the awful C.. for composition from Control.Category, why not just hide regular (.)?
20:16 <merijn> Since Control.Category.. works in all cases where (.) does
20:16 <dzdcnfzd> merijn: perhaps, but that's not really my problem right now
20:17 <merijn> dzdcnfzd: Yeah, but I'm tired and not getting much useful ideas on the actual problem :p
20:17 <Zemyla> shapr: If you do get it, or get ezyang to take submissions, PM me.
20:17 <dzdcnfzd> merijn: :)
20:17 <merijn> Kinda confused why they're reinveinting mmorph, tbh
20:17 <shapr> ok, sure
20:17 <ezyang> shapr: Did you want to take over TMR?!
20:17 <shapr> ezyang: maybe? it looks inactive?
20:18 <merijn> dzdcnfzd: Anyway, "import Prelude hiding ((.))" as first import should remove the need to qualify your use of (.) :)
20:18 <ezyang> yeah, I haven't had cycles ^^
20:18 <shapr> ezyang: but if you're working on it, I don't want to distract you
20:18 <shapr> ezyang: ok! sure!
20:18 <dzdcnfzd> merijn: I'll do that!
20:18 <shapr> I get to be first and fourth editor of TMR!
20:18 <shapr> unless there was someone between wouter and ezyang
20:19 <ezyang> byorgey
20:19 <merijn> dzdcnfzd: I'm not too sure what's going on with the real problem, sadly :)
20:19 <shapr> oh good, that makes me fifth editor
20:20 newhoggy joined
20:20 mokus joined
20:21 nicknovi1 joined
20:21 zeroed joined
20:21 zeroed joined
20:22 <merijn> Style question/poll: When moving the RHS of a function to a new line (because of being too long), should I move the = too?
20:23 <lpaste> merijn pasted “Style poll” at http://lpaste.net/354971
20:23 <Tuplanolla> I always go for option #1, because then I don't need to think about alignment, merijn.
20:24 <MonadHendrix> merijn: i submit to hindent
20:25 <shapr> Zemyla: sounds like you send the article to me!
20:25 <Zemyla> It should be in PDF and LaTeX format, or something?
20:25 rkazak joined
20:26 <shapr> Zemyla: yeah, I like LaTeX
20:26 <shapr> TMR started out as wiki-only article, but that changed to LaTeX so you could produce a downloadabel PDF
20:26 takle joined
20:26 <Zemyla> shapr: Would you accept LyX? I don't know raw LaTeX, but I can use a WYSIWYG LaTeX editor. :V
20:27 <shapr> maybe?
20:27 jer1 joined
20:28 fragamus joined
20:28 <fragamus> in ghci can I find out which import is associated with a given symbol
20:28 <Tuplanolla> It's like reading a disassembly, shapr.
20:28 <shapr> Tuplanolla: want to write a TMR article?
20:28 newhoggy joined
20:29 <shapr> Tuplanolla: when you put it that way, doesn't sound like I want lyx
20:29 <fragamus> i figgered it out
20:29 <shapr> fragamus: what was it?
20:29 <Tuplanolla> I'm building my own blog at the moment, shapr. Maybe later.
20:29 <shapr> ok
20:29 <fragamus> :i sym
20:29 osa1 joined
20:29 osa1 joined
20:29 <Squarism> is it possible to switch between with and wo "--profile" when using stack? accidently missing it seems to throw away everything and then wait for 10 minutes of recompiling w/ or wo profiling.
20:30 <MarcelineVQ> merijn: fwiw I also use option 1
20:30 wroathe joined
20:30 <kadoban> Squarism: I think there's a way to specify that stuff in the stack.yaml
20:30 <hexagoxel> merijn: maybe consider the case that you have one action, and add a "do" + a second one. "=" at end of line is nicer then.
20:30 <Squarism> kadoban, ok - ill check it out
20:31 <merijn> hexagoxel: I use "= do\n" for do blocks, yes. But I was wondering what'd be nicer for single lines
20:31 beanbagula joined
20:31 <eschnett> “=“ and “==“ are conceptually similar. where would you place the “==“? or another infix operator?
20:32 <merijn> eschnett: I tend to avoid linewrapping with infix operators
20:32 <merijn> Unrelatedly: In which directory does cabal run tests when you do "cabal test"?
20:32 aplund joined
20:32 <Tuplanolla> The low effort solution is to shove all the awkward things to the end of the line, merijn. The result is ugly too, which is a plus: http://lpaste.net/352328
20:32 <eschnett> merjin: there’s you answer — put it onto one line and use where?
20:32 <monochrom> merijn: I don't move the "=". In fact usually I write "f x =" one line, " x + x" next line (if "x + x" is long)
20:33 Snircle joined
20:33 <monochrom> I also write "f x = do" if "do" is involved.
20:33 newhoggy joined
20:34 Gurkenglas joined
20:34 <hexagoxel> merijn: yeah, i meant to focus on how much refactoring is necessary when you add/remove a second line.
20:34 <merijn> Good point, actually
20:36 slemonide joined
20:36 fkurkowski joined
20:39 fendor joined
20:39 `^_^v joined
20:40 <hexagoxel> (i might like \n= longexpr\n+ longexpr, but i also generally avoid such uses of infixops)
20:41 fendoer joined
20:41 soniku joined
20:42 xormor joined
20:42 iomonad joined
20:43 caumeslasal joined
20:43 zaquest joined
20:44 iAmerikan joined
20:44 ExpHP joined
20:45 sproingie joined
20:46 beanbagula joined
20:46 wroathe joined
20:47 <merijn> Using quickcheck and testy I need to generate some random filename and random short bytestring, any pointers?
20:48 jer1 joined
20:48 <merijn> Right now I'm just hardcoding a filename and some data, but that seems wrong
20:48 Blkt joined
20:49 sssilver joined
20:50 biglambda joined
20:50 seveg joined
20:51 newhoggy joined
20:51 JoshS joined
20:51 splanch joined
20:52 shainer joined
20:53 mattyw joined
20:57 newhoggy joined
20:58 <MarcelineVQ> does the bytestring become the file? is it a temporary file? does it get deleted after you use it or is it being compared to another file?
20:58 oish joined
20:58 Kototama joined
20:58 <merijn> MarcelineVQ: I'm creating a file temporarily to verify that it's getting deleted
20:59 mmachenry joined
21:01 dm3 joined
21:02 wroathe joined
21:02 fenedor joined
21:02 raichoo joined
21:04 mmachenry joined
21:04 tomphp joined
21:04 niteria joined
21:06 tv joined
21:06 <MarcelineVQ> I'd probably let the temporary package handle the file and filename, an issue with quickcheck is that generators tend to start simple so if you're using Test.QuickCheck.Gen to get a random bytestring you'll probably want to adjust the size of what you get. with the quickcheck-instances package you can get a random bytestring simply with generate (arbitrary :: Gen ByteString)
21:06 Aruro joined
21:07 nbro joined
21:09 jer1 joined
21:09 dopey_ joined
21:09 <MarcelineVQ> tasty also has support for golden tests, if that becomes useful to you now or later on, https://hackage.haskell.org/package/tasty-golden
21:11 chrisdotcode joined
21:11 texasmynsted joined
21:12 castlelore joined
21:14 Wizek_ joined
21:14 flatmap13 joined
21:14 Itkovian joined
21:15 bennofs1 joined
21:16 <merijn> Argh
21:16 flatmap1_ joined
21:16 <merijn> Why does Data.ByteString.hGetContents close the Handle? >.<
21:17 <merijn> Who the hell thought that was a good idea?!
21:17 <merijn> Anyway I can read a file completely into memory without closing the handle?
21:17 wroathe joined
21:18 <geekosaur> it's necessary
21:18 <Gurkenglas> Can I ask lambdabot whether a message was received, and should we add that?
21:18 <merijn> geekosaur: Why?
21:18 <MarcelineVQ> lazy bytestring?
21:18 <geekosaur> merijn, the Handle is handed to unsafeInterleaveIO. you cannot safely manipulate it afterward because it's accessed from pure code
21:18 <merijn> No, strict
21:18 flatmap13 joined
21:18 <merijn> geekosaur: Eh, why would it be handled to unsafeInterleaveIO?
21:18 yrdz joined
21:18 <MarcelineVQ> I​ mean is lazy bytestring a solution? idk much about them
21:18 <geekosaur> oh,strict bytestring, don;t know if it does the same thing
21:18 <merijn> This is strict, not lazy ByteString
21:19 pierrot joined
21:19 <geekosaur> but I would expect it to maintain the same API
21:19 <merijn> geekosaur: It does, else I wouldn't be running into this bug
21:19 <* geekosaur> goes looking
21:19 <merijn> That's really obnoxious, because it means I can't read a file multiple times by reseting via hSeek
21:19 <monochrom> I will still defend closing it. But I can see a minority of alternative use cases of not wanting it closed.
21:20 <merijn> monochrom: I could understand defaulting to closing, but there's no non-closing alternative
21:20 <geekosaur> the use a different API
21:20 <monochrom> OTOH history is written by historical reasons.
21:20 <geekosaur> isn't that hGetSome?
21:20 <monochrom> The strict case closes because the lazy case closed and no one at that time thought of alternatives.
21:21 <merijn> geekosaur: "use a different API" is basically "reimplement hGetContents"
21:21 <merijn> geekosaur: hGet and hGetSome require me to know the length I'm trying to read
21:21 <glguy> merijn: I know! go down to the unix layer and duplicate the file descriptor, use that to make a duplicate Handle, hGetContents that duplicated handle
21:22 <geekosaur> hGetContents is there to replicate an existing API. (One which imo kinda sucks anyway...)
21:22 <monochrom> hGetSome requires you to cite a number.
21:22 <merijn> glguy: Then the tests won't run on windows!
21:22 <glguy> What's windows?
21:22 strykerkkd joined
21:22 <monochrom> Haha glguy
21:22 <Tuplanolla> You can use seeking to find the size of the file, merijn.
21:22 <merijn> glguy: I don't care, but I don't see that helping my case to get my patch merged
21:22 <geekosaur> whatever, ok yes hGetContents should be a different API from hhGetContents elsewhere
21:22 <geekosaur> obviously nobody expects APIs to be the same
21:22 ckubrak joined
21:23 <glguy> merijn: Getting the operation you want exposed in the library is a good way forward, of course
21:23 <Tuplanolla> You're already seeking, so that shouldn't be much of a stretch.
21:23 bperez joined
21:23 <merijn> Is hGetSome guaranteed to basically be hGet when dealing with files?
21:23 <monochrom> I agree with Tuplanolla regarding getting it done today. For tomorrow, file a request.
21:24 <merijn> (I can probably manage an educated guess about the file length, but blocking indefinitely) would be a problem
21:24 <monochrom> Maybe you can just hGet and not worry about hGetSome
21:24 <geekosaur> hGetSome actually looks like it's intended more for sockets
21:24 <merijn> geekosaur: It is
21:24 <glguy> You shouldn't have to guess the length, you can query the file size
21:25 <geekosaur> so yes, hGet or hGetNonBlocking
21:25 <merijn> monochrom: Oh, wait, I suppose if I over guesstimate the size hGet will still return when it hits EOF
21:25 <geekosaur> yes
21:25 <monochrom> YES! ASK FOR 1TB! :)
21:26 <glguy> hFileSize :: Handle -> IO Integer
21:26 <merijn> glguy: Yes, I could, but my guesstimate is way easier to compute and doesn't require fiddling with annoying things :p
21:26 <glguy> easier to compute than importing it from System.IO?
21:26 <merijn> hmmm, I suppose hFileSize works
21:26 <merijn> glguy: I'll go with "equally easy, so I'll do the right thing"
21:26 <glguy> yay
21:27 aib joined
21:27 beanbagula joined
21:27 <monochrom> No no no. The easiest thing to do is to detect the file system and then look up a known table on wikipedia about maximum file size support for this file system and request that number of bytes.
21:27 <monochrom> (Just kidding!)
21:28 <Tuplanolla> Was my suggestion too complicated, merijn?
21:28 <monochrom> (But for example, if it's FAT32, just ask for 4GB. OK I'm done.)
21:28 NeverDie joined
21:28 <glguy> there's always 'maxBound'
21:28 <merijn> Tuplanolla: Well, first seeking, then querying the offset is less nice than simply using hFileSize :)
21:29 <glguy> Oh, I wouldn't recommend overguessing... hGetSome uses createAndTrim
21:29 <glguy> maxBound might be too big...
21:29 <* monochrom> was very surprised and annoyed when discovering for the first time he had an 8GB file to put on a FAT32 USB (32GB capacity) and the error message was "disk full" WTF?)
21:29 <MarcelineVQ> it almost might be too small, potentially
21:29 <bperez> I'm currently compiling something with -prof and am getting "Cannot load -prof objects when GHC is built with -dynamic"
21:29 <bperez> is there a good workaround for this?
21:29 jer1 joined
21:30 <MarcelineVQ> maxBound only gurantees.. 512 megs for Int?
21:30 <MarcelineVQ> > (2^29-1) / 1024 / 1024
21:30 <lambdabot> 511.9999990463257
21:31 <monochrom> You know what, my program uses both hFileSize and seek-and-thou-shalt-find. Because one of them works for files, the other works for /dev/sr0.
21:31 butterthebuddha joined
21:32 <monochrom> Here: https://github.com/treblacy/random-read/blob/master/random-read.hs
21:32 <monochrom> Actually you can safely scroll down to line 72 and I should have put that in the URL
21:33 wroathe joined
21:33 anuxivm joined
21:34 bsmt joined
21:38 uglyfigurine joined
21:39 sssilver joined
21:40 darjeeling_ joined
21:43 fotonzade joined
21:44 kamyar joined
21:45 <kamyar> Hello all
21:45 <kamyar> Please help me build a project using HaskForce plugin of IntellijIDEA
21:45 blender3 joined
21:45 <* merijn> sighs
21:46 <monochrom> Must you use IntellijIDEA and/or HaskForce?
21:46 <merijn> I keep having to wait for some slow stuff to finish to check whether it's still slow or I fixed it...
21:47 <monochrom> merijn: Yeah, it happens to me too when there is a disk error or slow website.
21:47 <monochrom> "I have to try 3 times to make sure. And each time takes 1 minute of waiting."
21:48 augur joined
21:48 <kamyar> monochrom: Leksah does not run on GHC 8.0.2, and is ther eany better IDE? BTW I get habit of JetBRains IDE's
21:48 <monochrom> Not to mention that so-called "1 try" is implemented by the lower layer by 3 low-level tries. Ah the fractal structure of tries.
21:48 <kamyar> I have used PyCharm and IntellijIDEA for ears
21:49 nbro left
21:49 <monochrom> kamyar, that doesn't really answer my question.
21:49 <kamyar> monochrom: What do u wanna know? u mean using a simple text editor?
21:50 <merijn> Yay! Fixed it
21:50 <merijn> Now it's fast :)
21:50 <monochrom> I want to know: Must you use IntellijIDEA and/or HaskForce?
21:50 <monochrom> What happened, merijn?
21:51 <kamyar> monochrom: No! It is my own project!
21:51 <monochrom> Then consider a simple "cabal init" and a text editor.
21:51 <merijn> monochrom: Writing tests for criterion and it was running the benchmark as much as it would to benchmark normally, whereas I just need one iteration to validate the results
21:51 <merijn> i.e. whether the test passes or fails
21:51 tonytherabbit joined
21:52 <merijn> So limiting iterations to 1 is much faster
21:52 <kamyar> monochrom: I guessed! I am now using stack builder not cabal
21:52 <kamyar> monochrom: alongside with textmate
21:52 <monochrom> OK, there is a stack way too, I just don't know it.
21:52 <kamyar> monochrom: But I like auto-completion and error corretcion features
21:52 hiratara joined
21:53 <Tuplanolla> Vim and Emacs have plugins for those, kamyar.
21:53 jer1 joined
21:53 MarioBranco joined
21:54 Eduard_Munteanu joined
21:54 <Tuplanolla> Pick your poison, I guess.
21:54 <kamyar> Tuplanolla: For completion? What is the name of emacs plugin ?
21:55 <kamyar> Tuplanolla: I am using mepla
21:55 <kamyar> Tuplanolla: *Melpa
21:55 <monochrom> haskell-mode
21:55 <monochrom> It does some completion but there are limitations.
21:56 <monochrom> I am a perfectionist. My flaw is I will keep looking for the perfect code in my head before I write down one single letter in the editor.
21:57 newhoggy joined
21:57 <kamyar> Tuplanolla: I have it installed. It does not have completion
21:57 <monochrom> Most of you don't have this flaw. But you have the dual flaw. You keep looking for the perfect editor or IDE or plugin before you write down one single letter of code.
21:57 <monochrom> Hell, even before that, you keep looking for the perfect font.
21:57 flatmap13 joined
21:58 <Tuplanolla> At all or of the kind you wish, kamyar?
21:58 <monochrom> So whereas I spend omega time, you guys spend omega+omega time.
21:58 <kamyar> Tuplanolla: dunno! I need Import and function call completion
21:59 conal joined
21:59 <Tuplanolla> I can't help you with those since I don't have them either, kamyar.
21:59 <Tuplanolla> There's always that one language extension or TH trick that wrecks any plugin.
22:00 javjarfer joined
22:01 unyu joined
22:01 ChaiTRex joined
22:02 dfeuer joined
22:03 <c_wraith> -XCPP breaks basically everything
22:04 yellowj joined
22:04 <thang1> What about IncoherentInstances combined with UndecidableInstances? You're basically guaranteed to have a fun time with a bottle of vodka :p
22:04 sigmundv joined
22:04 hpc joined
22:04 <c_wraith> those break programs, not parsers. :P
22:04 <thang1> a parser is a program, obvs /s
22:05 <monochrom> Does it break your vodka? :)
22:05 wroathe joined
22:05 <thang1> It helps me appreciate it, that's for sure
22:06 butterthebuddha joined
22:07 <thang1> http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/ I love it
22:10 ExpHP joined
22:11 <merijn> Right, time for bed and hoping all my tests will have succeeded in the morning, so I can start the endless process of badgering upstream to merge stuff...
22:11 <thang1> hah, nice. Good luck
22:11 sssilver joined
22:12 bjz joined
22:12 jer1 joined
22:13 oisdk joined
22:14 henriksod joined
22:16 Delpen9 joined
22:17 vtomole joined
22:18 actualHuman_452 joined
22:18 <monochrom> hahah thang1
22:19 <monochrom> "how far are you intending to take this?" "just two layers"
22:20 f0x joined
22:21 <f0x> leave
22:21 f0x left
22:21 Swizec joined
22:22 Swizec joined
22:23 Swizec joined
22:23 <thang1> ಠ_ಠ
22:24 Swizec joined
22:24 Gurkenglas joined
22:24 spopejoy joined
22:24 Swizec joined
22:25 slemonide joined
22:25 Swizec joined
22:26 butterthebuddha joined
22:28 iAmerikan joined
22:30 sboosali joined
22:31 hiratara joined
22:32 eschnett joined
22:33 jer1 joined
22:34 e14 joined
22:35 beanbagula joined
22:36 wroathe joined
22:39 mattyw_ joined
22:40 augur joined
22:43 e14_ joined
22:45 conal joined
22:45 nesqi joined
22:46 dan_f joined
22:46 jer1 joined
22:46 Aruro joined
22:46 Moto-chan joined
22:46 sproingie joined
22:46 sproingie joined
22:47 aarvar joined
22:50 Klumben joined
22:50 halogenandtoast joined
22:50 <halogenandtoast> Sometimes I'm convinced Haskell hates me...
22:50 raynold joined
22:50 <halogenandtoast> Expected type: IO (Maybe (IO (Maybe Text))) Actual type: Maybe (Maybe (IO (Maybe Text)))
22:50 <halogenandtoast> No idea how I've dug this hole.
22:51 falafel joined
22:51 <hpc> needs more Maybe
22:51 <davean> well
22:51 <hpc> or possibly more IO
22:51 <hpc> @lpaste
22:51 <lambdabot> Haskell pastebin: http://lpaste.net/
22:51 <davean> you can "join" out the first maybes
22:51 <davean> and return it all to get an IO
22:52 <davean> "return . join" and you're types match
22:52 <davean> though, uh
22:52 wires joined
22:52 <davean> I mean, I think you fucked something else up to get that
22:52 <halogenandtoast> davean: yeah I'm assuming I'm doing something very wrong in the first place
22:52 oisdk joined
22:52 <halogenandtoast> and the type system is just mad at me
22:52 <davean> As it probably should be
22:52 <hpc> can you paste your code?
22:52 <davean> halogenandtoast: so it sounds like its past you that hates current you, and Haskell is trying to save your ass ;)
22:53 wroathe joined
22:53 <lpaste> halogenandtoast pasted “MoreIO.hs” at http://lpaste.net/354973
22:53 beebe23 joined
22:53 <halogenandtoast> I THINK that's the relevant code
22:53 <davean> ... and I'm out
22:53 <halogenandtoast> It's quite possible some of the things I'm doing (fmap, liftIO) aren't needed, but I've been type-flailing
22:54 <beebe23> join
22:54 <halogenandtoast> ha sorry davean, out of curiosity what do I do to KO you?
22:54 <halogenandtoast> I'm going to blame Yesod, but if it was something I did, let me know.
22:54 <davean> halogenandtoast: Oh, I'm just alergic to Yesod :)
22:54 <halogenandtoast> ha fair enough
22:55 <Tuplanolla> When's Nood?
22:55 <halogenandtoast> beebe23: join in front of the liftIO?
22:55 <davean> If I try to help you I'll just end up angry
22:55 <davean> And I like being happy
22:55 darlan joined
22:56 newhoggy joined
22:56 <halogenandtoast> Yeah that's fair, I don't actually think this is a Yesod problem
22:56 <halogenandtoast> I think I'm just a bad.
22:56 cloudhead joined
22:57 <davean> halogenandtoast: of course, but I'd have to read the yesod docs
22:58 <halogenandtoast> I think the only Yesod part is lookupPostParam which is IO (Maybe Text)
22:58 binaryplease joined
22:58 jmcarthur joined
22:58 <halogenandtoast> hashPasswordUsingPolicy is crom Crypto.BCrypt and is IO (Maybe ByteString)
22:58 <halogenandtoast> well HashingPolicy -> ByteString -> IO (Maybe ByteString)
22:59 <halogenandtoast> s/crom/from/
23:00 <halogenandtoast> Anyways, I'll do some more type-flailing later, time to record a podcast.
23:01 <Eduard_Munteanu> halogenandtoast, fmap digestPassword gives you a Maybe (IO ...)
23:01 <halogenandtoast> Eduard_Munteanu: yeah I tried removing the fmap
23:02 <halogenandtoast> Wich has less wrapping, but is still wrong
23:02 slemonide joined
23:02 <Tuplanolla> You probably want to `mapM_` over the `Maybe` or `sequence_` the stack to transpose the monads, halogenandtoast.
23:02 refold joined
23:02 <Eduard_Munteanu> Yup ^.
23:03 <Eduard_Munteanu> digest <- mapM (liftIO . digestPassword) password
23:03 frew joined
23:03 <halogenandtoast> Hmm there's a new error, I'll have to check out the types and see what that's doing
23:03 <halogenandtoast> Thanks for the help all
23:03 rkazak joined
23:04 slemonide1 joined
23:04 <Eduard_Munteanu> You need the Traversable-based mapM
23:04 <halogenandtoast> I keep forgetting you can use things like mapM for things that aren't lists
23:04 dfeuer joined
23:04 Koterpillar joined
23:05 <Tuplanolla> Another way to look at it is that the last `ByteString` in `HashingPolicy -> ByteString -> IO (Maybe ByteString)` is the point of four levels of functors, so you can `fmap` to it and `join` the result.
23:05 Fairy joined
23:05 e14 joined
23:05 <Tuplanolla> Only for entertainment though.
23:05 <halogenandtoast> Alright have to get ready now, thanks everyone for the help, I'll reference this conversation and see if I can fix it a bit later.
23:06 xacktm joined
23:07 bjz joined
23:07 ljc joined
23:07 hc joined
23:07 soniku joined
23:08 taktoa joined
23:08 seanparsons joined
23:08 wroathe joined
23:09 newhoggy_ joined
23:10 <Tuplanolla> :t fmap . fmap . fmap . fmap :: Functor f => Functor g => (a -> b) -> (HashingPolicy -> ByteString -> f (g a)) -> (HashingPolicy -> ByteString -> f (g b)) -- It doesn't get better than this.
23:10 <lambdabot> (Functor g, Functor f) => (a -> b) -> (HashingPolicy -> ByteString -> f (g a)) -> HashingPolicy -> ByteString -> f (g b)
23:10 Goplat joined
23:10 <Eduard_Munteanu> :t fmap `fmap` fmap `fmap` fmap `fmap` fmap
23:10 <lambdabot> (Functor f, Functor f1, Functor f2, Functor f3) => (a -> b) -> f3 (f2 (f1 (f a))) -> f3 (f2 (f1 (f b)))
23:11 refold joined
23:12 nilof joined
23:12 ExcelTronic joined
23:13 jer1 joined
23:13 halogenandtoast joined
23:16 Rodya_ joined
23:16 slemonide joined
23:16 orhan89 joined
23:17 dfeuer joined
23:22 crave joined
23:22 fakenerd joined
23:22 conal joined
23:23 cdg joined
23:24 wroathe joined
23:24 smillmorel joined
23:26 abel-abel joined
23:26 newhoggy joined
23:30 newhoggy_ joined
23:30 SolarAquarion joined
23:31 beanbagula joined
23:31 jer1 joined
23:32 roconnor joined
23:32 <actualHuman_452> Does anyone know of some sort of documentation/tutorial/written explanation for us mortals that might explain the Monad instance of (->) ?
23:32 beerdrop joined
23:33 <Zemyla> actualHuman_452: Okay, let's go through the types.
23:33 <Zemyla> return is type a -> m a. In this case, with m = (->) e, return :: a -> e -> a.
23:33 dolio joined
23:33 <Zemyla> What function do you know with type a -> e -> a?
23:34 mizu_no_oto_work joined
23:34 <actualHuman_452> const?
23:34 <Zemyla> Yep.
23:35 juhp joined
23:35 <Zemyla> Then we have (>>=) :: m a -> (a -> m b) -> m b. It becomes (>>=) :: (e -> a) -> (a -> e -> b) -> e -> b.
23:35 <Zemyla> Write a function that solves this.
23:37 MP2E joined
23:38 <mniip> well that's the implementation
23:38 <mniip> the meaning though
23:39 u-ou joined
23:39 sellout- joined
23:39 <jmcarthur> This path may be easier: actualHuman_452, do you understand Reader?
23:39 louispan joined
23:40 lambda-11235 joined
23:40 Axman6 joined
23:40 <Zemyla> actualHuman_452: Okay, the meaning is that it provides an "environment" of type e. This environment is passed to every subcomputation in the monad.
23:42 <Zemyla> In a do block, you can fetch it with something like env <- id.
23:42 dbmikus joined
23:43 <actualHuman_452> Right, following
23:43 Achylles joined
23:44 halogenandtoast joined
23:47 vargeek joined
23:48 <Zemyla> That's basically all there is to it.
23:48 <Zemyla> It's an uncomplicated monad.
23:49 tv joined
23:49 <monochrom> I think you should still try your hands at writing that function.
23:50 Rodya_ joined
23:50 <monochrom> At present it is best to use the desired type to guide writing the code.
23:50 cretiq joined
23:50 <monochrom> Afterwards, you can ponder on "what does this code mean?" and it will be valuable too.
23:51 <monochrom> But use the known certainty to solve the unknown uncertainty. Not the other way round.
23:51 <monochrom> At present the type is the known certainty.
23:52 nakal joined
23:52 vargeek_ joined
23:52 alem0lars joined
23:52 louispan joined
23:52 <Zemyla> I mean, take a look at sequence for it.
23:52 <Zemyla> sequence :: [e -> a] -> e -> a.
23:53 jer1 joined
23:53 <Zemyla> sequence :: [e -> a] -> e -> [a], rather.
23:53 <monochrom> Yeah, I was wondering :)
23:53 <Zemyla> :t \a b -> sequence a b
23:53 <lambdabot> Traversable t1 => t1 (t -> a) -> t -> t1 a
23:53 markus1209 joined
23:54 markus1219 joined
23:54 <actualHuman_452> So, this actually comes back to the problem that got me on this whole tack - bindF f y v = (y (f v) v)
23:54 Leachmanh_ joined
23:54 YongJoon joined
23:54 <Zemyla> actualHuman_452: Precisely. See how v is used twice.
23:54 darlan joined
23:55 plutoniix joined
23:55 sgronblo joined
23:55 wroathe joined
23:56 <monochrom> It is nice to visualize a function (of type K->V) to be a huge table of V's using K's for keys. Lookup table.
23:57 cschneid_ joined
23:57 <monochrom> (and all lookups always succeed, all keys are present, unlike pilthy Data.Map and hash tables :) )
23:58 theDon_ joined
23:59 <monochrom> bindF f y (aka f >>= y) means: lookup in table f, then pass the answer to y to obtain yet another table, then lookup in that table. (I am deliberately hiding away "v". In all lookups, use v for the key throughout)
23:59 infinity0 joined