<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 _2_5 26 27  
28 29 30 31
00:00 infinity0 joined
00:00 mjora7 joined
00:00 crobbins joined
00:00 <thang1> rightfold: and the reason you want that referentially transparent mutation with linear types is so that you can keep reasoning but also allow the compiler ot do some awesome witchcraft and potentially negate the need for a GC for certain parts of the code entirely, right?
00:00 <rightfold> Yes
00:00 <rightfold> A mutation is safe if nobody can observe it. Mutations are super fast.
00:00 fowlslegs joined
00:01 <pacak> Btw, in paper and in all discussion I've seen they used unicode dot rather than o. Is there established ascii version? -o looks odd.
00:02 <thang1> Mutations are also safe if people can observe but can't change and you ensure that all viewing references have updates, or something like that? (Rust has done a lot of work into this kinda stuff iirc)
00:02 <pacak> this type signature is valid o -o o -o o - but ugly.
00:02 <thang1> -o is the closest to an established ascii version as we're going to get, I think
00:02 <rightfold> pacak: it's also known as "lollipop" and "multimap"
00:02 <suzu> safe if everybody can observe the new value, nobody can observe the old one, and hence nobody can observe that there was a mutation
00:02 infinity0 joined
00:03 <pacak> rightfold: How do you type it in ascii? Actuall -o?
00:03 <thang1> suzu: right, that makes sense. Atomic and instantaneous mutations that can be safely treated as not-a-mutation as far as reasoning goes
00:03 <suzu> yup
00:03 <EvanR> turing machine is based on observable mutation and is perfectly safe
00:03 <rightfold> thang1: in Rust, you cannot dereference any reference except the unique reference-to-mutable, if such a reference-to-mutable exists. This ensures a certain degree of safety, but not referential transparency that we are interested in with functional programming
00:04 <thang1> Yeah but you can't have some random non-local other turing machine kamakazi into the middle of your first turing machine and wipe out half of it because of a buffer overflow
00:04 <nshepperd> nothing infinitely big is perfectly safe
00:04 lambda-11235 joined
00:04 <EvanR> Z ?
00:05 <thang1> rightfold: thanks. I really need to get off my butt and learn Rust so I can internalize some of these concepts better.
00:05 infinity0 joined
00:06 <nshepperd> I've been wanting linear types in my embedded DSL for automatic differentiation, so that I can require certain type class constraint only when something is used twice (or zero times)
00:06 <rightfold> If you have a function A -> A, that mutates its input, and you have a guarantee that the input is the ONLY reference to the value, then the function call referentially transparent.
00:06 <nshepperd> but you only need indexed monads to do that, and i haven't bothered yet
00:06 bobakk3r joined
00:07 <rightfold> thang1: you may want to look at Mercury too
00:08 <rightfold> nshepperd: do you have a link to info on this EDSL?
00:08 infinity0 joined
00:09 <biglambda> ertes: So it turns out the simplest solution was to move the typeclass function into the dependant class. If that makes any sense.
00:09 <nshepperd> no, I only have code. i'm using it for machine learning, and the DSL is for composing differentiable functions (neural networks)
00:09 <biglambda> That’s one to file away into the bag of tricks.
00:11 infinity0 joined
00:11 <rightfold> nshepperd: ok!
00:11 jer1 joined
00:12 <thang1> rightfold: thanks! I've seen it before in some research as well. I'm also interested in Erlang style languages for that actor model stuff
00:13 rblaze1 joined
00:13 <EvanR> still waiting for an abstract version of the actor model
00:13 codesoup joined
00:13 infinity0 joined
00:15 <nshepperd> you don't need linear types if you use a Category/Arrowish interface for composition, as the only way you can copy things would be 'copy :: Copyable a => c a (a,a)'. but doing everything in pointless style is a pain in the ass
00:15 Costar joined
00:17 robatosan joined
00:18 sleffy joined
00:18 bairyn joined
00:19 <monochrom> Linearity by too much hassle to clone. :)
00:19 tromp joined
00:19 <EvanR> nshepperd: but wait! you could use a quasi quoter to convert expressions of the form x y z -> z x y into the proper swaps and copies
00:20 <rightfold> pointfree quasiquoter
00:21 plutoniix joined
00:21 <EvanR> and then your compile time goes through the roof
00:21 JoshS joined
00:22 crobbins joined
00:23 mac10688 joined
00:24 <nshepperd> EvanR: I could write my own ArrowSyntax, yeah
00:24 hc joined
00:25 <EvanR> well what i suggested takes up a lot less space
00:25 <pacak> :t aside
00:25 <lambdabot> (Applicative f, Choice p) => APrism s t a b -> p (e, a) (f (e, b)) -> p (e, s) (f (e, t))
00:26 <pacak> aside operates on second element of a tuple. How do I get something that operates on the first one?
00:26 fosterite joined
00:30 jedws joined
00:30 hexfive joined
00:31 blym_ joined
00:32 jer1 joined
00:36 haskell-beginner joined
00:37 jao joined
00:37 kav joined
00:37 <thang1> (,) is not a tuple it is a pair
00:38 <haskell-beginner> parse error (possibly incorrect indentation or mismatched brackets)
00:38 <EvanR> and (,,) is not a triple?
00:38 <thang1> haskell-beginner: thx bro
00:38 <pacak> A tuple is a finite ordered list of elements. In mathematics, an n-tuple is a sequence (or ordered list) of n elements, where n is a non-negative integer.
00:38 <EvanR> er, i mean to say, tuple
00:38 <pacak> pair = 2-tuple
00:38 <thang1> Right
00:39 augur joined
00:39 <haskell-beginner> please can you help me
00:39 <EvanR> so a square is not a rectangle
00:39 <EvanR> because its not non-square
00:39 <thang1> > length (4,5) -- I'm just saying, thinking of this as a "tuple" is going to make things weird
00:39 <lambdabot> 1
00:39 <pacak> haskell-beginner: Paste full error message somewhere?
00:39 <haskell-beginner> how do I make a haskell functio find the value of a quadratic
00:39 kernelj_arch joined
00:40 <EvanR> the result of length (4,5) in haskell is a pretty bad excuse to change what we call tuples
00:40 <pacak> What's the least perverted way of making left aside?
00:40 <haskell-beginner> where: quadratic = x^2 +5x + 1
00:41 <pacak> > [x | x <- [-10 .. 10], x*x + 5 * x + 1 == 0]
00:41 <lambdabot> []
00:41 <EvanR> theres the quadratic formula and some tweaks to attempt to migitigates its bad numeric behavior
00:41 <antoine9298> “left aside”?
00:41 pfoetchen joined
00:41 <EvanR> mitigate?
00:41 <pacak> > [x | x <- [-10,-9.9 .. 10], abs (x*x + 5 * x + 1) < 0.1]
00:41 <lambdabot> [-4.8000000000000185,-0.20000000000003482]
00:42 <thang1> EvanR: sure, but if you want a true programming convention of "n-tuple" in the language to be denoted by (,,, ... ,), we don't really have a way to do that right now.
00:42 <pacak> haskell-beginner: here :)
00:42 <haskell-beginner> hello_world.hs:1:1: error: Parse error: naked expression at top level Perhaps you intended to use TemplateHaskell
00:42 dfordivam joined
00:42 <EvanR> thang1: since youre shaking some established jargon here, i have no idea what youre talking about
00:42 <pacak> antoine9298: aside applies prism to second element of a tuple. I want to modify first one.
00:43 <dogbits> haskell-beginner, can you post link lamda lpaste.net
00:43 <thang1> EvanR: http://bitemyapp.com/posts/2015-10-19-either-is-not-arbitrary.html I just read this today, so that has something to do with it :p
00:43 <antoine9298> hmm, not sure about “prism” either, but, ok, I guess so
00:44 <EvanR> thang1: ah, some polemic blog post from chris ;)
00:44 <thang1> But the main point is really that anything with Functor is going to act on the second part of the "tuple". If you want to modify both parts, you want a bifunctor, and if you want some arbritrary choice, you want a lens
00:45 sanitypassing joined
00:45 <thang1> EvanR: I do freely admit that am easily influenced by shiny examples...
00:45 <pacak> :t _Left
00:45 <lambdabot> (Applicative f, Choice p) => p a (f b) -> p (Either a c) (f (Either b c))
00:45 <haskell-beginner> http://lpaste.net/355203
00:45 <pacak> > preview _Left (Right 1)
00:45 <lambdabot> Nothing
00:45 <haskell-beginner> dogbits: http://lpaste.net/355203
00:45 <pacak> > preview _Left (Left 1)
00:45 <haskell-beginner> pacak: http://lpaste.net/355203
00:45 <lambdabot> Just 1
00:46 cpennington joined
00:46 <pacak> antoine9298: Kind of pattern match thingy.
00:46 andyhuzhill joined
00:46 <thang1> That being said, a n-tuple is (,) or (,,) or (,,,) for any n number of arguments. If I were expecting length (a,b) to give me 2, I would be expecting a tuple structure to be arbritrary amounts of arguments
00:46 <Sonolin> do lens type signatures ever get easier to read?
00:46 <haskell-beginner> hello_world.hs:5:1: error: parse error (possibly incorrect indentation or mismatched brackets)
00:46 <Sonolin> lol
00:46 acarrico joined
00:46 <haskell-beginner> hello_world.hs:5:1: error: parse error (possibly incorrect indentation or mismatched brackets)
00:46 <robkennedy> Status Report: It turns out that later in the paper they define `copy :: (a -> r) -o a -o r`
00:46 <thang1> But in haskell, there's only (,) by "default"
00:47 <pacak> haskell-beginner: first two lines - they do nothing. Last line - you don't need let.
00:47 <pacak> Sonolin: Well... They are flexible.
00:47 <thang1> robkennedy: mah gawd, have they gone completely mad?
00:47 <haskell-beginner> pacak: I'm using the $ ghc
00:47 <pacak> > :t _Left
00:47 <lambdabot> <hint>:1:1: error: parse error on input ‘:’
00:47 <pacak> :t _Left
00:47 <haskell-beginner> pacak: bc I don't know how to get the IDLE thingy
00:47 <lambdabot> (Applicative f, Choice p) => p a (f b) -> p (Either a c) (f (Either b c))
00:47 Noldorin joined
00:47 oisdk joined
00:47 <pacak> :t _Left :: Prism' (Either a b) a
00:47 <lambdabot> (Applicative f, Choice p) => p a (f a) -> p (Either a b) (f (Either a b))
00:48 <EvanR> thang1: i dont expect length (x,y) to be 2
00:48 <EvanR> i dont expect it to be anything, i dont plan on using this god forsaken Foldable instance
00:49 louispan joined
00:51 Gurkenglas_ joined
00:51 <robkennedy> I hate that instance as much as I hate `length $ Just [1,2,3]`
00:52 <robkennedy> > length (Just [1..5])
00:52 <lambdabot> 1
00:52 <antoine9298> > liftM lenght (Just [1..5])
00:52 <lambdabot> error:
00:52 <lambdabot> • Variable not in scope: lenght :: [Integer] -> r
00:52 <lambdabot> • Perhaps you meant one of these:
00:52 <pacak> > sum (1,2)
00:52 <lambdabot> 2
00:52 kav joined
00:52 <antoine9298> > liftM length (Just [1..5])
00:52 <lambdabot> Just 5
00:52 <pacak> > sum ("string", 2)
00:52 <antoine9298> yay!
00:53 <lambdabot> 2
00:53 <haskell-beginner> how do I call the custom function
00:53 <haskell-beginner> doesn\t seem to work
00:53 <haskell-beginner> x 3
00:53 <haskell-beginner> quadratic.hs:5:1: error: Parse error: naked expression at top level Perhaps you intended to use TemplateHaskell
00:53 joseCova joined
00:53 <thang1> > fmap length (Just [1..5])
00:53 <lambdabot> Just 5
00:53 <pacak> haskell-beginner: You don't just call a function, you need to do something with results
00:53 <haskell-beginner> http://lpaste.net/355203
00:54 <EvanR> one does not merely call a function?
00:54 <EvanR> nvm
00:54 <kernelj_arch> > length <$> Just [1..5]
00:54 <lambdabot> Just 5
00:54 <pacak> haskell-beginner: replace second line with
00:54 <pacak> main = print $ x 3
00:54 <EvanR> main = print (x 3)
00:54 cschneid_ joined
00:55 <pacak> main = let (☭) = ($) in print ☭ x 3
00:55 <haskell-beginner> pacak: quadratic.hs:2:16: error: • Couldn't match expected type ‘Integer -> a0’ with actual type ‘[Integer]’ • The function ‘x’ is applied to one argument, but its type ‘[Integer]’ has none In the second argument of ‘($)’, namely ‘x 3’ In the expression: print $ x 3
00:55 <pacak> Hmm...
00:55 <pacak> You don't need 3
00:55 <pacak> so
00:55 fosterite joined
00:55 <pacak> main = print x
00:55 <thang1> @import Data.Bifunctor
00:55 <lambdabot> Unknown command, try @list
00:55 jer1 joined
00:55 <thang1> >import Data.Bifunctor
00:56 <thang1> :t first
00:56 <lambdabot> Arrow a => a b c -> a (b, d) (c, d)
00:56 <thang1> :t Bifunctor.first
00:56 <lambdabot> error:
00:56 <lambdabot> Not in scope: ‘Bifunctor.first’
00:56 <lambdabot> No module named ‘Bifunctor’ is imported.
00:56 <thang1> ಠ_ಠ
00:57 <antoine9298> any practical differency between fmap and liftM (except that one works with functors and the other one with monads)?
00:57 <EvanR> fmap works with all of the above
00:57 <EvanR> liftM doesnt
00:57 <haskell-beginner> pacak: what do you mean
00:57 <pacak> antoine9298: fmap is shorter to type.
00:57 <thang1> antoine9298: pretty sure there's not any major difference now that we've screwed with our typeclasses a bit. liftM feels like a backwards compatibility thing that we still have hanging around
00:57 scottj joined
00:57 <EvanR> fmap doesn't require an import
00:57 <antoine9298> EvanR why ?
00:57 <pacak> And you can type it even if your shit/capslock keys are broken.
00:58 <EvanR> because all Monads are Functors anyway
00:58 jordan39593 joined
00:58 <pacak> haskell-beginner: replace first line with
00:58 <pacak> main = print x
00:58 <pacak> haskell-beginner: second line
00:58 <jordan39593> hi
00:58 <jordan39593> https://ideone.com/QqoLSW
00:58 <antoine9298> EvanR …and that’s harder to get a monad instead of a functor, right?
00:58 <jordan39593> why does this short program give me an error
00:59 <haskell-beginner> pacak: then what do I do to use the function with x = 3 ?
00:59 <pacak> jordan39593: funktion is too short, it lacks body.
00:59 <EvanR> antoine9298: i guess Monads are less common, but precisely, all Monads are Functors but not all Functors are Monads
00:59 <jordan39593> what do you mean too short
00:59 plot joined
00:59 <jordan39593> what do i need to do to make it work
00:59 <pacak> haskell-beginner: Are you trying to evaluate a quadratic formula?
01:00 <pacak> jordan39593: type more stuff.
01:00 <antoine9298> → So there can’t be more monads, so they are more functors
01:00 <jordan39593> is it because i use " | " ?
01:00 <antoine9298> have you got examples of things that can be functors but not monads?
01:00 <latro`a> haskell-beginner, why did you re-use the symbol x in the definition of x? don't do that...
01:00 <EvanR> antoine9298: im not sure you can really counter the number of either, its infinite
01:00 <pacak> jordan39593: No, it's a guard pattern, that's perfectly valid. But you are not telling it what to do.
01:00 <latro`a> antoine9298, iirc ZipList
01:01 <antoine9298> yeah, of course, but from a practical PoV
01:01 <jordan39593> what do i have to change to make it work for example?
01:01 <latro`a> what's not practical about ZipList?
01:01 <haskell-beginner> pacak: These were the instructions we were given: 1) Use a text editor such as Notepad ++ to write a function to find the value of quadratic where: quadratic = x^2 +5x + 1 Save your function as quadratic.hs
01:01 ryantrinkle joined
01:02 <antoine9298> just like, there is an infinite number of numbers, and an infinite number of primes, but from a practical PoV, there is less primes
01:02 <ryantrinkle> any news on when linear types might be showing up?
01:02 <pacak> jordan39593: Switch to a different language, haskell is static typed one.
01:02 <pacak> haskell-beginner: I see, Try this
01:02 <latro`a> oh, you weren't talking to me, I gotcha
01:02 <pacak> main = print (f 3)
01:02 <pacak> f x = x * x + 5 * x + 1
01:02 <pacak> haskell-beginner: Just two lines.
01:02 <jordan39593> its a task i have to do
01:02 <haskell-beginner> 2) Load and run your program to find the value of quadratic when x = 3
01:02 <jordan39593> i cant switch languages lol
01:03 yepo joined
01:03 <EvanR> antoine9298: well, i can give you an example. but im not going to support imprecise "practical" terminology
01:03 robertkennedy joined
01:03 tromp joined
01:03 <antoine9298> jordan hmm, you’ll have to get the “haskell way”, I guess
01:03 <pacak> jordan39593: What is your task then?
01:04 <jordan39593> i want to filter numbers from a list
01:04 <jordan39593> the list is a string
01:04 darjeeling_ joined
01:04 <antoine9298> why would you need more that statical types?
01:04 <pacak> > filter isDigit "123abc45"
01:04 <lambdabot> "12345"
01:04 <haskell-beginner> pacak: it just says [1 of 1] compiling main then linking quadratic...
01:04 <haskell-beginner> pacak:
01:04 <haskell-beginner> nothing prints
01:05 <antoine9298> I love that bot
01:05 <pacak> haskell-beginner: Did you executed the program itself?
01:05 <pacak> ghc only compiles stuff
01:06 cranej joined
01:06 <pacak> jordan39593: By numbers you probably mean digits.
01:06 <jordan39593> yes
01:06 <haskell-beginner> pacak: So I have to compile it each time then sudo chmod +x then ./filename?
01:06 <pacak> And in your paste you apply characters, not strings to function
01:07 <haskell-beginner> pacak: that's a lot of effort
01:07 thimoteus joined
01:07 <pacak> haskell-beginner: simply ./filename will do
01:07 splanch_ joined
01:07 <jordan39593> how can i like save all digits in the string to a new list
01:07 <jordan39593> in my function
01:07 <kernelj_arch> haskell-beginner: there's a 'runhaskell' command that can run your script directly
01:07 <haskell-beginner> pacak: what's the .hi one for
01:07 <pacak> jordan39593: funktion = filter isDigit
01:07 <pacak> haskell-beginner: It contains the essense of divine haskellness, you don't need it at the moment.
01:08 <jordan39593> that doesnt do anything
01:08 <haskell-beginner> pacak: what do you use this language for practically?
01:08 <pacak> haskell-beginner: Making money.
01:09 <haskell-beginner> pacak: lol but what do they want you to create for them
01:09 <thang1> (☞゚ヮ゚)☞ excellent answer, pacak
01:09 sellout- joined
01:09 <haskell-beginner> pacak: or what programs generally could work exclusively off haskell
01:10 <EvanR> haskell is a general purpose programming language
01:10 <pacak> haskell-beginner: You can write all sorts of stuff in Haskell
01:10 lambdamu joined
01:10 <kernelj_arch> You can also write all sorts of stuff in any other language
01:10 louispan joined
01:10 <haskell-beginner> pacak: outside academia though?
01:10 <pacak> haskell-beginner: Yes.
01:11 <pacak> kernelj_arch: Right, but in inferior languages it can be painful.
01:11 <jordan39593> "inferior languages"
01:11 <pacak> kernelj_arch: http://stackoverflow.com/questions/43740037/datetime-converts-wrong-when-system-time-is-30-march - take this for example
01:11 gabriel_ joined
01:11 <EvanR> probably the wrong way to put it
01:11 <kadoban> haskell-beginner: It has great support for web stuff, especially server side. There's GHCJS for doing client-side web stuff in it, you can use it for any general application programming you can think of. It's really general purpose.
01:12 <pacak> jordan39593: php, javascript.
01:12 <EvanR> if i was doing this game is javascript, itd probably be done by now
01:12 <pacak> kernelj_arch: https://i.imgur.com/6aclmM6.png - or this
01:12 <kernelj_arch> is that javascript?
01:13 <haskell-beginner> kadoban: it's gonna take me a while to see how math functions are more useful to write web apps in than high level language
01:13 <pacak> kernelj_arch: second link - yes.
01:13 <haskell-beginner> *non-functional high level
01:13 <EvanR> haskell-beginner: dont look now, web page templates are pure functions
01:13 <EvanR> web forms are applicative functors
01:13 <haskell-beginner> EvanR: well yes technically all computer science is maths
01:13 <haskell-beginner> EvanR: but
01:14 <haskell-beginner> EvanR: from the backend development side, why would I need lambda
01:14 <EvanR> the response of a webserver is (unless you need to wait for secondary responses) a response body and a transaction
01:14 <kadoban> haskell-beginner: It seems weird as hell at first, but it'll make perfect sense eventually. It's really just a more sound way of modelling the computation that you probably already know how to do in other languages, plus some extra guarantees that you can't quite get in other lanugages.
01:15 <EvanR> and if you do, you have a free monad
01:15 jer1 joined
01:15 <haskell-beginner> kadoban: so basically just efficiency?
01:15 <yepo> Is Haskell good for machine learning / AI?
01:16 <EvanR> haskell-beginner: after i realized templates are "just functions" it became much easier to actually write the template, because so much redundancy was removed. higher order functions really let you factor out a lot of repeated code
01:16 <kadoban> haskell-beginner: No, though haskell is pretty efficient in terms of speed for a high level language. I'd say safety and sanity/flexibility of expressing patterns and thoughts.
01:17 ridho joined
01:17 <kernelj_arch> pacak: I don't see much wrong with that javascript one given how in javascript everything is treated like a string pretty much, but string + string = concatenated string
01:18 <haskell-beginner> kadoban: doesn't it also mean a lot more work. I can understand how it is safer for development since you know exactly what when and how the program will execute but for ordinary web devs there is a huge cost in terms of time if they write their own engines
01:18 <yepo> not Haskell in particular but Functional Programming in general. Most languages are capable to some degree for FP ammirite?
01:18 <kadoban> haskell-beginner: No, over time it's far less work for me. A type system is a tool that helps you reason about and work with code. A really nice tool once you get used to it.
01:18 <EvanR> haskell-beginner: well, theres are several engines
01:18 <EvanR> and i have spent plenty of time fixing or understanding bugs in rails
01:19 <pacak> kernelj_arch: Well... It leads to some unexpected conversions for one.
01:19 eacamero_ joined
01:19 <pacak> I'd rather have a type error when I try something like this
01:19 <pacak> > 1 + "3"
01:19 <lambdabot> error:
01:19 <lambdabot> • No instance for (Num [Char]) arising from a use of ‘+’
01:19 <lambdabot> • In the expression: 1 + "3"
01:19 <pacak> lambdabot: Thank you.
01:19 filterfish joined
01:19 <haskell-beginner> kadoban: we use frameworks so that we don't waste time in the more technical details. What's the point in writing everything as f(x) = x | x -> ... etc
01:19 <kernelj_arch> pacak: I didn't find any of them unexpected because like I said, javascript can treat everything as a string
01:19 <pacak> kernelj_arch: In javascript there's... http://dorey.github.io/JavaScript-Equality-Table/
01:20 fosterite joined
01:20 <EvanR> haskell-beginner: you really get used to code not crashing at runtime
01:20 <EvanR> its kind of a game changer
01:20 <EvanR> but it does require you to think differently
01:20 fizbin joined
01:21 Tene joined
01:21 <EvanR> and that difference can be transported back to normal languages
01:21 <jordan39593> https://ideone.com/Pk9sP4
01:21 <jordan39593> why cant i run the simplest program
01:21 <haskell-beginner> EvanR: I'm not sure what you've been using that's crashing all the time due to something other than your code
01:21 <dyreshark> haskell-beginner: haskell has frameworks. many of them. https://wiki.haskell.org/Web/Frameworks
01:21 <EvanR> haskell-beginner: pretty much
01:21 Supersonic112_ joined
01:22 <EvanR> *my* code crashes a lot less in haskell
01:22 splanch joined
01:22 <haskell-beginner> It only makes sense if you're doing a very different kind of web app
01:22 <jordan39593> Parse error: naked expression at top level
01:22 <jordan39593> Perhaps you intended to use TemplateHaskell
01:22 <jordan39593> haskell gives the most useless errors i have ever seen
01:22 <haskell-beginner> but for normal web apps there's really nothing wrong with PHP w/ laravel on an NGINX
01:22 <pacak> EvanR: Not crashing at runtime? Hmmm.... Can you imagine situation where this function can crash?
01:22 <pacak> derp :: Int -> Int -> Int
01:22 <pacak> derp a b = if a == b `xor` show a == show b then undefined else a + b
01:23 <EvanR> pacak: my tea timer for someone to chime in and say haskell can crash just went off
01:23 xcmw joined
01:23 <pacak> jordan39593: Here, take dis! "="
01:23 <EvanR> haskell-beginner: there you go thn
01:24 <dyreshark> haskell-beginner: see also http://adit.io/posts/2013-04-15-making-a-website-with-haskell.html for a thing that shows you actual code that uses (some of) those frameworks
01:24 <jordan39593> wow
01:24 <dyreshark> though it's potentially a bit out of date
01:24 <jordan39593> it worked
01:24 <EvanR> 2013 web haskell, man thats old
01:24 <dyreshark> still has concise examples
01:24 <kadoban> haskell-beginner: Frameworks exist in haskell, seems like a false dichotomy.
01:25 <haskell-beginner> kadoban: not really a false dichotomy when they are extremely different
01:25 <kadoban> In what way are they extremely different (and from what?)
01:25 <haskell-beginner> kadoban: haskell just adds unnecessary work
01:25 <pacak> haskell-beginner: Saves you from one actually.
01:25 <haskell-beginner> kadoban: why would you need to do this
01:25 <dyreshark> depends on your definition of unnecessary
01:25 <haskell-beginner> dyreshark: for common use
01:26 <EvanR> broken PHP is still in production use, wasting peoples time
01:26 <kadoban> I strongly disagree.
01:26 <dyreshark> if i'm deploying something, i want as much assurance as possible it's not horribly broken
01:26 <dyreshark> haskell's type system helps with that
01:26 <dyreshark> it doesn't guarantee anything, mind you
01:26 <dyreshark> but it helps
01:26 <EvanR> legacy PHP is a time sink that keeps on sinking
01:26 <pacak> haskell-beginner: it compiles therefore it works is much more likely to apply to haskell rather than javascript. Or php.
01:27 <haskell-beginner> EvanR: it is possible to make a secure PHP app
01:27 slemonide joined
01:27 <EvanR> i found it very difficult personally, even thinking i was proficient with it
01:27 <haskell-beginner> EvanR: have you used frameworks
01:27 <haskell-beginner> with PHPp
01:27 <EvanR> yeah several PHP frameworks
01:27 <kadoban> It's possible to make a secure app in machine language, by manually flipping one bit at a time. It's just not very easy. A better question is which tool helps do so better.
01:27 <haskell-beginner> Hmm
01:27 <EvanR> and write my own, like many people
01:28 <EvanR> custom CMS
01:28 <rotaerk> hmm would I be "weird" if I started using literate haskell by default
01:29 <kadoban> For some definitions of weird I suppose.
01:29 <kernelj_arch> I've got an interview with Jane Street and I don't know whether to learn OCaml in a hurry, do Haskell which I have recent experience with or stick with C++
01:29 sword865 joined
01:29 <haskell-beginner> how do I pass in values when I executed the compiled code
01:29 <kernelj_arch> they say to use the language you're most comfortable with, and I can't figure out how much they mean it
01:29 slemonide joined
01:30 <EvanR> cramming on C++, Haskell, or OCaml for an interview in the near future?
01:30 <haskell-beginner> ./file --variable1 "bhnmd,'"
01:30 <haskell-beginner> like that
01:30 <kadoban> haskell-beginner: Same was as in any program. Via command line arguments, read from files or stdin, via sockets, etc.
01:30 <kernelj_arch> EvanR: yes
01:30 <pacak> :t getArgs
01:30 <lambdabot> error: Variable not in scope: getArgs
01:30 <kernelj_arch> probs within 2 weeks
01:30 <EvanR> haskell-beginner: theres is a library which gives you nice option parsing for this, optparse-applicative
01:31 <taktoa> kernelj_arch: I used haskell on my phone interview and I didn't get another interview, though I was a freshman at the time
01:31 <thang1> https://github.com/groupoid/om this looks super neat
01:31 <pacak> haskell-beginner: Might be tricky for beginners. You'll have to use scary M-word.
01:31 <johnw> does anyone know why z3 would be giving me "invalid usage" on this code: https://gist.github.com/259ae8ffb9cb7452949e1a190ec08744
01:31 <johnw> I find examples on the web where exists and forall are nested...
01:31 <kernelj_arch> taktoa: mind divulging what sort of stuff they asked?
01:31 <EvanR> pacak: the task doesnt have much to do with Monads
01:32 halogenandtoast joined
01:32 <pacak> EvanR: IO monad at least.
01:32 <EvanR> IO doesnt have much to do with "Monad"
01:32 <MP2E> it uses the IO type, it doesn't necessarily require knowledge of the Monad instance :p
01:32 a3Dman joined
01:32 <EvanR> you need to use IO, thats for sure
01:32 <EvanR> and probably do notation
01:33 <EvanR> and with optparse-applicative, youre not using much of either
01:35 <pacak> "If not, don't worry! All you really need to learn are a few basic parsers, and how to compose them as instances of Applicative and Alternative."
01:35 <EvanR> you kind of dont even need to understand those classes
01:35 <EvanR> just do like in other languages and translate from the examples!
01:36 jer1 joined
01:36 <EvanR> (which dont even show you the types)
01:36 <EvanR> (so its not scary at all)
01:36 <pacak> =<<, <>, <**>...
01:37 <pacak> I'm not even sure myself what <**> is.
01:37 <pacak> :t (<**>)
01:37 <lambdabot> Applicative f => f a -> f (a -> b) -> f b
01:37 <ChaiTRex> It's a spider.
01:37 <pacak> k, something stupid.,
01:37 <haskell-beginner> is there an IDLE like thing for haskell
01:38 kav joined
01:38 <EvanR> the repl is ghci
01:39 Koterpillar joined
01:39 <haskell-beginner> Why's it called prelude
01:39 <haskell-beginner> prelude>
01:39 <EvanR> it comes first
01:39 <haskell-beginner> is there an interlude then
01:39 <benzrf> it sounds cool
01:39 <EvanR> probably
01:39 <haskell-beginner> probably?
01:39 <EvanR> there are many alternative preludes
01:39 <EvanR> which should cut down on some more common imports
01:40 <haskell-beginner> 'it comes first' ? what comes after?
01:40 <EvanR> your code
01:40 <haskell-beginner> oh so this is for testing
01:40 <EvanR> your imports
01:40 kamyar joined
01:40 <kamyar> hello guys
01:40 <EvanR> no, its an invisible import before any of the others in all modules
01:40 kernelj_arch joined
01:40 <kamyar> I have a simple question
01:40 <johnw> ah, found it, I had counted off the de Bruijn indices wrong
01:41 <benzrf> haskell-beginner: Prelude is the name of the module that is imported without you saying so
01:41 <benzrf> haskell-beginner: python has this too, it's just not named
01:41 <haskell-beginner> benzrf: oh fair
01:41 <kamyar> How can we determine if a block of code is running strict or lazy?
01:41 <benzrf> kamyar: all code is lazy in haskell unless it is using bang patterns or seq
01:41 <haskell-beginner> putStrLn
01:41 <haskell-beginner> What is Ln
01:42 <EvanR> line
01:42 <pacak> Line
01:42 <pacak> end of line specifically
01:42 <yepo> I'm (re)learning programming and Haskell is a breath of fresh air
01:42 <haskell-beginner> put string to end of line?
01:42 <kamyar> benzrf: what is bang?
01:42 <pacak> kamyar: !
01:42 <benzrf> kamyar: an extension
01:42 <EvanR> ! is called bang, # is called octothorp
01:43 <kamyar> benzrf: I have heard we can change parts of code behavior
01:43 stoopkid joined
01:43 <kamyar> benzrf: for example for IO monad
01:44 louispan joined
01:45 acarrico joined
01:45 <haskell-beginner> how does haskell do these factorials of huge numbers so quickly
01:45 katsura joined
01:45 <kamyar> It surely depends on how I code and which types I use e.g. Text or Lazy Text
01:45 <EvanR> its just repeated multiplication
01:45 <katsura> hi
01:46 <kamyar> but I need a general queue
01:46 <EvanR> but with arbitrary precision integers
01:46 <kamyar> sorry clue
01:46 <haskell-beginner> yeah but these are huge numbers and usually it would be a time complexity problem
01:46 slemonide joined
01:46 <haskell-beginner> let fac n = if n == 0 then 1 else n * fac (n-1)
01:46 <EvanR> multiplication of large numbers has efficient algorithms
01:46 <haskell-beginner> fac 100000
01:47 <EvanR> > product [1..100000]
01:47 <lambdabot> mueval-core: Time limit exceeded
01:47 robatosan joined
01:47 <haskell-beginner> so is there a nice one liner for calculating pi to x many digits
01:47 <kamyar> I have heard neglecting lazy evaluation can be a killer e.g. menory leak
01:47 <EvanR> > pi :: CReal
01:47 <lambdabot> 3.1415926535897932384626433832795028841972
01:48 <EvanR> > pi
01:48 <lambdabot> 3.141592653589793
01:48 <kamyar> is therr any tools or manual methods to check code?
01:48 <haskell-beginner> pi
01:49 <haskell-beginner> pi to maybe 100 digits
01:49 <EvanR> kamyar: ghc has a built in profiler
01:49 <EvanR> CReal gives you reals to however many digits
01:49 <yepo> Noob question: what's the difference between > b = 32 VS. > let b = 32 ??
01:49 <kamyar> EvanR: does it check leaks or bad laziness?
01:50 <pacak> kamyar: you can use vacuum to see if stuff is evaluated or not.
01:50 <EvanR> you can look at graphs of memor usage
01:50 <EvanR> if you dont think its supposed to be growing growing, you may have done something wrong
01:50 <kamyar> pacak: how does it work?
01:50 <EvanR> but thats a big if
01:51 <pacak> kamyar: http://hackage.haskell.org/package/vacuum-
01:51 <pacak> There's vacuumLazy that gives you a node map that you can walk around
01:51 <pacak> Version on hackage is outdated but I maintain my own version.
01:51 <benzrf> yepo: in ghci?
01:52 sellout- joined
01:52 <yepo> benzrf: yes
01:53 <benzrf> yepo: former is an error before ghc 8
01:53 <kamyar> pacak: thnx!
01:53 <yepo> benzrf: so then both are valid in the latest versions? Thanks!
01:53 cschneid_ joined
01:53 <benzrf> yepo: yup
01:54 dan_f joined
01:55 jsgrant_om joined
01:56 <monochrom> Wait, what?!
01:56 <* monochrom> tries
01:56 <benzrf> :)
01:56 jer1 joined
01:56 <monochrom> I be damned.
01:56 <benzrf> now u can do this:
01:56 <benzrf> :{
01:57 <benzrf> a :: Int
01:57 <benzrf> a = 3
01:57 <benzrf> :}
01:57 <Unode> with all those smilies, it's hard to keep a straight face
01:57 <monochrom> Now I can't wave my "the REPL is not an editor" anymore.
01:57 <monochrom> err, "the REPL is not an IDE".
01:57 <Unode> the multiline edit is still cumbersome
01:58 <MarcelineVQ> it's nice for pasting in though
01:58 Koterpillar joined
01:58 <Unode> :set +m , is what I learn on the book.
01:58 mmachenry joined
01:58 <monochrom> To be fair, supporting "b = 3" is uncontroversial, there is no ambiguity as far as GHCi grammar is concerned.
01:59 takle joined
02:00 <Unode> there's also ipython with the haskell kernel. But getting it to work is a bit of a PITA.
02:00 hucksy_ joined
02:02 DrMentats joined
02:02 xxalien8dxx joined
02:05 chao-tic joined
02:05 andyhuzhill joined
02:05 <benzrf> mmm, pita
02:06 <Unode> there's docker, but that's kind of throwing away everything else you might have setup.
02:06 <yepo> > [2,2..20]
02:06 <lambdabot> [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2...
02:06 <yepo> Why is this?
02:06 <benzrf> yepo: i'm sure it'll get there eventually o3o
02:07 <geekosaur> "for sufficiently large values of 2"
02:07 <EvanR> what in the
02:07 <benzrf> yepo: that means, "starting from 2, let the next thing be 2, and keep going up by the same amount, stopping when you reach 20"
02:07 <geekosaur> the syntax expands to enumFromThenTo
02:07 <ChaiTRex> GHC is, for some reason, really slow compiling 720000-line functions.
02:07 <benzrf> ChaiTRex: lol
02:07 <yepo> benzrf: thanks
02:07 <benzrf> no problem :)
02:08 <EvanR> benzrf: it does this by subtraction?
02:08 carlomagno joined
02:08 <EvanR> > [2,4..7] :: [Double]
02:08 <lambdabot> [2.0,4.0,6.0,8.0]
02:09 <benzrf> i think so
02:09 <EvanR> gnarly
02:09 <benzrf> dunno
02:09 darlan joined
02:09 <ChaiTRex> > [2,4..7::Int]
02:09 <lambdabot> [2,4,6]
02:09 <ChaiTRex> O-o
02:09 <benzrf> what in the heck
02:10 <Unode> so 8.0 < 7 ?
02:10 <EvanR> i guess enumFromThenTo can do whatever it wants since its in the Enum class
02:10 <pacak> > [1.0, 2.0 .. 10]
02:10 <lambdabot> [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0]
02:10 <glguy> counting by 2 , you won't reach 7
02:10 <pacak> > [1.0, 2.0 .. 9.99]
02:10 <lambdabot> [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0]
02:10 <ChaiTRex> > fromEnum (8.0 :: Double)
02:10 <lambdabot> 8
02:10 <ChaiTRex> > fromEnum (7.0 :: Double)
02:10 <lambdabot> 7
02:11 <pacak> Because everyone knows that 10.0 < 9.99
02:11 <pacak> All heil satan!
02:11 <Unode> interesting features
02:12 <EvanR> yes
02:12 <pacak> (haskell report is strange)
02:12 <EvanR> quotes around various parts of that phrase
02:13 <Engen> hey guys I'm trying to do some exercises regarding GADTs and I'm having trouble understanding both how they help and some syntax
02:13 andyhuzhill joined
02:13 <Engen> to start off with, I've been given a definition for a binary tree http://lpaste.net/355206
02:14 <EvanR> that is just GADT syntax and isnt using GADTs extra features
02:14 <EvanR> so the way its used there is just for looks
02:14 <kernelj_arch> what are the extra features?
02:15 <EvanR> the type of the result of construction can be something besides BinaryTree a
02:15 <Engen> I don't understand line 3 how we begin with a BinaryTree and take two two more BinaryTrees to return another BinaryTree
02:15 <benzrf> Engen: you're just writing the type of the constructor
02:15 <kernelj_arch> you mean like BinaryTree b or something completely different?
02:15 takle joined
02:15 <benzrf> Engen: in GADT syntax, you just straight up write the type of each constructor. if it's not a type you can assign to a constructor, you;ll get an error
02:15 <EvanR> BinaryTree Char, BinaryTree (a, Char), BinaryTree (ArbitraryTypeLevelExpr)
02:16 <EvanR> kernelj_arch: or just b, yeah, which could do interesting things if only a is in scope
02:16 Goplat joined
02:16 <benzrf> Engen: note that the 'a' in the type of Leaf is bound implicitly just like in the type of a function; the 'a' in the first line of the data declaration is a separaet variable - try changing one of them, it will still work
02:17 jer1 joined
02:17 <Engen> benzrf: ah I get you, it's just a placeholder
02:18 <benzrf> Engen: in the first line, yeah
02:18 <EvanR> if you wrote data BinaryTree a = Leaf a | Branch a (BinaryTree a) (BinaryTree a) and check Branch's type, itd look just like that
02:18 <benzrf> the 'a' in the first line merely serves to indicate BinaryTree's arity
02:19 <glguy> It's best to enable the KindSignatures extension and write: data Tree :: * -> * where ...
02:19 <benzrf> in languages like coq, you could write [Inductive BinaryTree : Type -> Type] and it would mean the same thing
02:19 <glguy> than to have the confusing variable there
02:19 <benzrf> jinx!
02:20 <EvanR> clearly haskell doesnt like "theres only one way to do it"
02:20 <benzrf> tim toady
02:20 e14 joined
02:20 chao-tic joined
02:21 louispan joined
02:22 takle joined
02:22 <monochrom> GHC 8 allows Type->Type too
02:22 biglambda joined
02:22 <benzrf> sick
02:22 <monochrom> There are always at least two ways to do it. Do it yourself or hire someone else.
02:23 <Engen> yeah, I'm just trying to understand what this allows for
02:23 <Cale> "There's never less than infinitely many ways to do it"
02:23 <Cale> maybe not as catchy
02:23 <thang1> monochrom: Type->Type where? In the `data X where` line?
02:24 <monochrom> Tree :: Type -> Type
02:24 <monochrom> In general, * is Type
02:25 <EvanR> are they trying to eventually shift from * to Type?
02:25 <Engen> benzrf: because the next part says to make a data type called Tag that has two variants, Empty and NonEmpty. to my understanding, this simply is data Tag = Empty | NonEmpty
02:25 <benzrf> whose bright idea was it in haskell to call it :: instead of :
02:25 <EvanR> something about making it easier to parse
02:25 <benzrf> EvanR: probably they want you to use gadt syntax
02:25 <kernelj_arch> coq has that weird hierarchy though where the types of things in programs are represented by 'Set' which has a type of 'Type' which has a type of 'Type' in the next universe up
02:25 <Engen> and then it says to adjust the GADT type of BinaryTree to be indexed by one of those two types
02:25 <monochrom> I think yes, they said * is a parsing nightmare.
02:25 <benzrf> *engen
02:25 <benzrf> oh i see
02:25 <monochrom> or maybe just grammatical nightmare but still
02:25 <benzrf> Engen: yeah the ordinary way should be fine then
02:25 <Engen> how does one index on whether something is Empty or NonEmpty
02:26 <thang1> benzrf: historical gafe. When Haskell was invented, everyone had a giant hardon for linked lists, so of course the best way to express that is to make linked lists as easy as humanely possible to create
02:26 <benzrf> Engen: add another argument to BinaryTree so that it's 2-ary
02:26 <benzrf> thang1: yeah i figured
02:26 <benzrf> still!
02:26 <benzrf> Engen: make that argument of kind Tag
02:27 <kernelj_arch> thang1: so that's why haskell uses : and not :: for cons, I see
02:27 <thang1> Why use :: for list when you can use : ? And thus, oh no, : can't be used for types anymore... darn... well there's always ::. And so forever and ever amen will Haskell be weird and slightly wrong :p
02:27 <monochrom> Consider it Huffman code. The more frequent thing is given the shorter name.
02:27 <thang1> (completely ignoring the fact that types should be more frequent than lists)
02:27 <EvanR> yet i have way more types in my code than lists
02:28 <glguy> I'm happy with the arrangement of : and ::, I'm more likely to match a couple of cons cells like x:y:z than I am to do something like that with type signatures
02:28 <thang1> Like I said, original Haskell design team was in the 80s. Everyone had a giant fetish for linked lists back then :p
02:28 <monochrom> That was a time when lists were more frequent than types.
02:28 <EvanR> thang1: and i suspect not writing any type signatures
02:28 <monochrom> Type inference plus "we use lists for everything"
02:28 <EvanR> if not necessary
02:28 <Cale> Lists are *still* really quite important
02:28 anuxivm left
02:29 <EvanR> you will see ocaml and F# code without any signatures at all
02:29 <Cale> (even once you eliminate all the things they're bad at)
02:29 <thang1> Cale: they're an excellent tool for control flow, but they're terrible for storing data
02:29 <Cale> yes
02:29 <benzrf> hue
02:29 <monochrom> SML is the reverse because you write all top-level types twice.
02:29 <thang1> So you shouldn't be encouraging the construction of lists, then, you should encourage their consumption :p
02:29 <Cale> But consumption involves pattern matching against conses
02:29 splanch joined
02:29 Xanather joined
02:29 <Cale> Often enough
02:29 <benzrf> owned
02:30 <thang1> eh, true. Good point
02:30 <* thang1> puts on tinfoil hat of crazy-talk
02:30 <EvanR> you dont need pattern matching!
02:30 <EvanR> just use the list destructor
02:31 doomlord joined
02:31 <thang1> What if we got rid of ::, made : for types if it's surrounded by whitespace and : for list pattern matching if it's got no white space?
02:31 <benzrf> thang1: you have to die now
02:31 <EvanR> agda did that
02:31 splanch_ joined
02:31 <thang1> function : [a] -> a; function (x:xs) = x
02:31 mmachenry joined
02:31 <monochrom> parsing nightmare
02:31 <thang1> EvanR: Agda uses : for types, and unicode :: for list though?
02:32 <EvanR> ive never tried lists in agda
02:32 <thang1> monochrom: I am in no way being serious with this suggestion :p
02:32 <monochrom> haha ok
02:32 <thang1> That's why I put my crazy-talk tinfoil hat on lol
02:32 zcourts joined
02:32 <thang1> Further, Agda uses a ton of unicode everywhere
02:32 <EvanR> you have to have space on both sides of every operator
02:32 splanch__ joined
02:32 <EvanR> which i didnt realize was really annoying until it was made illegal not to
02:33 <thang1> http://www.cse.chalmers.se/~nad/repos/lib/src/Data/List.agda
02:33 tromp joined
02:33 <glguy> thang1: The use of unicode everywhere just depends on which libraries you pick from, the agda-prelude doesn't the "stdlib" does
02:33 <thang1> ∷ <-- this unicode symbol is used for list Cons in Agda
02:33 <Cale> When they can just use ,
02:34 <thang1> glguy: I should rephrase more to say that the Agda culture is a huge fan of unicode and I see it used darn near everywhere in user code as well
02:34 <kernelj_arch> ∷ʳ for append, how cute!
02:34 <glguy> For example Ulf avoids it
02:34 <glguy> It's not built into the language, in particular, so cons can be whatever you want
02:35 juiko joined
02:35 <thang1> Cale: why would you use , for lists?
02:35 splanch joined
02:35 <kernelj_arch> I preferred using the unicode syntax in Coq which you had to enable, it just makes more sense in these sorts of languages
02:35 systemfault joined
02:35 watabou joined
02:35 <thang1> Definitely. The more mathematical and expressive a language gets, the more limiting the ASCII subset is
02:36 <yepo> Why do Haskell users strive to be lazy?
02:36 <EvanR> eventually unicode gets limiting
02:36 <Cale> thang1: Because you can :)
02:36 <glguy> yepo: I'll tell you later
02:36 <EvanR> like there is only a subset of latin letter subscripts for some reason
02:36 <thang1> it becomes more about the transformation of patterns and composition, and you really need a very large and expressive inputset for that
02:36 <MP2E> haha
02:37 <thang1> yepo: laziness is efficiency
02:37 <thang1> so named by people who don't understand efficiency
02:37 <yepo> glguy: lol
02:38 exferenceBot joined
02:38 takle joined
02:38 jer1 joined
02:38 <thang1> EvanR: What I would really like is a programatic way to design glyps and stuff like that so literally anything can be a subscript, literally anything can be a superscript, etc. Writing and designing 2D layout of text or even 3D layout
02:38 <thang1> Now that would be cool, to see a language that was 3D...
02:38 <EvanR> o_O
02:38 <EvanR> well you have that already, postscript
02:39 <thang1> postscript is 3D?
02:39 <Unode> perspective
02:39 <EvanR> im not even going to think about 3D text
02:39 <EvanR> right now
02:40 <EvanR> how many dimensions of text are you on
02:40 splanch_ joined
02:40 <thang1> a 2D language is actually really useful
02:40 <thang1> I'd consider written 'standard' text (english, chinese, etc) all "1D"
02:40 <Unode> 1.58 dimensions I'd say
02:40 <monochrom> Why did Einstein want more dimensions? To get more corners for his Einstein notation.
02:40 <Unode> :)
02:41 <thang1> However, there's actually a written language being developed for sign language right now and it's epic
02:41 <Engen> benzrf: does this make sense? http://lpaste.net/4440987087323267072
02:41 <Unode> thang1: ? so you code with hand glyphs?
02:41 <fosterite> we already have a written language for sign language: the language the sign language is based on
02:42 <thang1> No, I don't lol
02:42 <thang1> https://en.wikipedia.org/wiki/SignWriting#/media/File:Jack_and_Jill.gif
02:42 v0id_NULL joined
02:42 <Unode> fosterite: well but if you can show the finger to your webcam and your computer tells you "Hello World!" it's a whole new dimension.
02:42 <thang1> This is the Jack and Jill poem in ASL but then written in SignWriting
02:42 <benzrf> Engen: that's a valid type! but it's not what they want, probably
02:42 hexagoxel joined
02:42 <benzrf> Engen: here's where gadts have power: you can write type signatures that are impossible to create with the normal syntax
02:43 <benzrf> e.g.: "Leaf :: BinaryTree NonEmpty b"
02:43 <thang1> Signwriting used to be a 1 dimensional language, but it was changed to a 2D language because its linearity was dramatically slowing down the rate of comprehension that was possible
02:43 <glguy> Empty?
02:43 <benzrf> glguy: er, yes!
02:43 <kernelj_arch> shoud it not be "top :: BinaryTree a b -> b"
02:43 <benzrf> Engen: (here we're promoting Empty to a type-level value with kind Tag)
02:43 <Engen> benzrf: so you can explicitly say exactly what you expect where as normally you can't?
02:43 <Unode> thang1: looks like another variation of Chinese/Japanese/<insert (asian) language based on glyphs>
02:44 JeanCarloMachado joined
02:44 <thang1> Unode: it's different in this case. Chinese and Japanese are merely vertical, they're not two dimensional
02:44 <MarcelineVQ> Unode: the difference is due to it communicating actions you can skip some of the language barrier
02:44 <MarcelineVQ> at least one difference anyway
02:44 <thang1> Each column represents one "word"
02:44 <benzrf> Engen: exactly what you'll *return*
02:44 <Unode> well I'd still need to learn it cause I've no idea what that .gif is conveying
02:45 <thang1> However in Sign Language, you can't just express the sign, you have to give the hand shape, the body movement, the facial expression, etc
02:45 <MarcelineVQ> frankly I don't like it at all but there's merits to it
02:45 <thang1> The key concept with SignWriting is that each sign in ASL has 3-5 necessary characteristics that all must be interpreted "at once" to have a correct sign.
02:45 <thang1> So rather than writing a1 a2 a3 a4 a5 b1 b2 b3 b4 c1 ...
02:46 <thang1> It's much more powerful and understandable to group every characteristic of a sign into one column so that your brain can parse column-wise and row-wise at the same time
02:47 <thang1> (because in each column, seeing how each item changes over time is also important, so you want a clear path to map things over time in your head)
02:48 ryxai joined
02:48 <thang1> So there's an entire category of expression that is enabled with sign language and with ASL that's either incredibly verbose or just plain not really possible in spoken languages. And a 2D written form is necessary to clearly describe that extra dimensin of expression
02:48 <Engen> benzrf: I see
02:49 takle joined
02:49 <thang1> MarcelineVQ: 2D language or the other conversation that's going on? :p
02:50 <MarcelineVQ> mostly just the example image above
02:52 <thang1> ah got it. Yeah it can take some getting used to. If you want, I can translate it?
02:52 JeanCarloMachado joined
02:53 <MarcelineVQ> sure, if it translates into haskell :>
02:53 <EvanR> 2D language? or 2D script?
02:53 nomicflux joined
02:53 slemonide joined
02:54 <thang1> Sorry, 2D script and a 3D language
02:58 louispan joined
02:58 filterfish joined
02:58 jer1 joined
02:59 blym_ joined
02:59 louispan joined
02:59 ddere joined
02:59 et09_ joined
03:00 <et09_> how suitable is aeson for making a gtk json editor?
03:00 plot joined
03:00 <c_wraith> It's fine, but it's a hilariously small part of that project
03:00 <et09_> what project?
03:00 <et09_> my hypothetical project?
03:01 flatmap13 joined
03:01 MP2E joined
03:01 xcmw joined
03:02 <c_wraith> yes
03:03 <et09_> you mean because gtk is a nightmare
03:03 JeanCarloMachado joined
03:03 <c_wraith> No, I mean because it gives you a parser, a printer, and a tree data structure to represent parsed JSON
03:03 <c_wraith> Every part of any gui is far more work than those
03:04 felixsch__ joined
03:04 <et09_> gtk does? GtkTreeView ?
03:04 <c_wraith> No, aeson's Value type is a parsed JSON tree
03:05 <et09_> it seems like you set up a big FRP machine and send signals to gtk converting that json tree into a GtkTreeView, no?
03:05 <et09_> well, the changed parts
03:06 <EvanR> if that sounds easy, then aeson should be a cinch
03:06 <et09_> lol ok
03:06 otto_s joined
03:07 takle joined
03:08 robkennedy joined
03:08 argent0 joined
03:08 JeanCarloMachado joined
03:11 ChaiTRex joined
03:11 blym_ joined
03:11 Argue joined
03:12 <Engen> benzrf: still around?
03:13 <benzrf> Engen: yeagh
03:14 <Engen> I don't understand why this compiles http://wklej.org/hash/7e167b49153/
03:14 xall joined
03:14 systemfault joined
03:14 <Engen> there's no Tag data in line 8 for the function top to take into account
03:15 <EvanR> the Tag is not in the data itself, its only in the type
03:15 biotty joined
03:15 <EvanR> it doesnt exist at runtime
03:16 <Engen> so the reason I ask this is when I run top Leaf in ghci, I get a non-exhuastive patterns in function top exception
03:16 <EvanR> theres no case for Leaf
03:16 <Engen> and I've been trying to figure out how to place Empty and NonEmpty types inside of it...
03:16 <Engen> oh...
03:17 JeanCarloMachado joined
03:17 <EvanR> you dont because Empty and NonEmpty are types
03:17 robatosan joined
03:18 <EvanR> you should change the signature to top :: BinaryTree NonEmpty b -> b
03:18 <Engen> yeah, I'm trying to understand this and I apologise for you guys repeating yourselves
03:18 <EvanR> because it looks like you wont be able to get anything out of a Leaf
03:19 <biotty> independent question from me, a pre-newb. haskell has runtime info on which type-constructor a value used right? but not the type, because that was all matched at compile-time and erased. is my understanding not too far off?
03:19 jer1 joined
03:19 LuckyRawApe joined
03:19 <EvanR> types are used at compile time for various things and then erased
03:19 <biotty> that answers one part of my question
03:20 <EvanR> the data constructors will be there at runtime so your case expressions will work
03:20 <biotty> so i got it right, phew
03:20 <EvanR> pretty much
03:20 <biotty> this is all kind of a mind blower, i have been reading a couple of haskell intros
03:21 <EvanR> but ex. Leaf and Branch might be something as simple as 0 and 1
03:23 takle joined
03:24 <biotty> as i imagined
03:25 <biotty> just like a tagged union from dirty c
03:25 dfordivam joined
03:25 eacameron joined
03:26 <EvanR> its the same thing, just with a type system that reflects that usage pattern
03:26 <biotty> yes. i like it.
03:27 plot joined
03:27 hamishmack joined
03:27 <EvanR> you wont have the opportunity to accidentally access the wrong field of the union
03:28 <biotty> i am not a new to the world of programming ; )
03:29 <biotty> was kinf of digging to the bottom of c++ and now saw haskell and introduced myself to category theory with that too
03:29 <EvanR> as simple as this seems... im still kind of amazed its not a thing in the big OOP languages
03:29 <EvanR> even dynamic ones
03:30 <biotty> which concept of haskell do you refer to?
03:30 dfordivam joined
03:30 <EvanR> in clojure, the pattern would be [:mytag component1 component2] and use pattern match macro to case on it
03:30 <EvanR> sum types
03:31 <EvanR> but in OOP its like... an object inheritance hierarchy or something
03:31 <biotty> right. i dont know clujure sorry. was pretty new to functional programming languages just now
03:31 <EvanR> and you put the case body inside the class
03:31 <biotty> inheritance hierarchy is from the 80s, its crapp
03:31 <EvanR> so every case you ever do with a sum type is in the class
03:31 <EvanR> each class
03:31 <EvanR> haskell is from the 80s ;)
03:31 leothrix joined
03:32 <biotty> sure, but its from the future
03:32 <EvanR> haha
03:32 <biotty> its good
03:32 <EvanR> haskell is from the future of bill and ted, be excellent to each other
03:32 mmachenry joined
03:33 zcourts joined
03:35 xtreak joined
03:36 takle joined
03:39 chris_ joined
03:39 indi_ joined
03:39 louispan joined
03:39 jer1 joined
03:40 scottj left
03:41 <thang1> biotty: inheritance is pretty great
03:42 <thang1> Java and C++'s instance on ruining inheritance by making it unusable is a real shame because the idea itself has tons of merit
03:43 <biotty> sure it has its uses. i feel it has had its overuse thats all. hey, how do they ruin -- i am not aware of this
03:43 JeanCarloMachado joined
03:43 <thang1> Inheritance is the idea that things with identical properties can share implementations of "methods" that act on those properties
03:44 takle joined
03:44 <thang1> So for example, Int is a number, and Fraction is a number. They're both numbers, so why must I define addition separately for both?
03:44 begriffs joined
03:44 <thang1> Even worse, without inheritance, if I want addition to work "intuitively" I have to define it for Int + Int, Int + Fraction, Fraction + Int, Fraction + Fraction
03:45 <thang1> With inheritance, it "just works"
03:45 tromp joined
03:45 <thang1> C++ and Java thought "oh golly gee willikers, this is the best thing ever" and promptly forced you to write classes that tightly bind the concept of inheritance, methods, variables, etc., all together.
03:46 louispan joined
03:46 <begriffs> Is there a function to escape a Text or ByteString value for being inside a double quotes? i.e. replacing \ with \\ and " with \" ? I can write my own and all but thought maybe there would be one readymade.
03:46 <thang1> So you can't talk about inheritance without all of the baggage of OOP and now any "inheritance" is in the context of entire classes, not properties of classes
03:46 revtintin joined
03:47 <thang1> After all the damage had been done, people discovered that interfaces were way better than inheritance. Haskell, however, has always had "interface style inheritance" and so avoids the whole mess by only considering inheritance hierarchies of /types/, not methods
03:48 <biotty> thang1: i feel inheritance of implementation should be separated from inheritance of interface somehow better
03:48 <EvanR> you dont even need inheritance of implementation
03:48 <EvanR> because implementations are values, functions
03:48 <EvanR> you can make other functions out of functions
03:48 <EvanR> reuse of code
03:49 <thang1> Which is the magic of haskell's style of inheritance. /True/ polymorphism rather than the brittle polymorphism of OOP code
03:49 <biotty> yes.
03:49 <EvanR> what was revealed to me a few years ago was that reuse of code isnt the point, its access to locally-global variables
03:49 <EvanR> your methods have access to all the "globals" of its ancestor classes
03:49 <EvanR> you cant really do that in haskell
03:49 <EvanR> and a lot of people would say you dont want to
03:49 mmachenry joined
03:50 <thang1> And yet over and over OOP is taught in universities and books as "omg this inheritance". Really, nobody cares. You want the encapsulation of globals in OOP
03:50 lambdaman joined
03:50 <thang1> Which is conveniently handled by modules in Haskell
03:50 <EvanR> its not
03:50 <EvanR> because mutable
03:50 <thang1> You never really mutate anything in haskell anyway?
03:51 <EvanR> i wish
03:51 <thang1> Well sure there's monad transformer stacks and all that jazz, but I've never gotten the point of lexically scoped mutable globals if it means bringing in all that other crap that OOP delivers
03:52 <EvanR> agreed
03:52 <DrMentats> begriffs: applying show to a string should do it I think
03:52 JeanCarloMachado joined
03:52 <thang1> biotty: anyway, rather than wanting to inherit implementation of things, you can just write functions that work on everything that shares certain properties (which is really what you want in the first place)
03:53 <thang1> So you /could/ write addition as Int + Int = Int
03:53 shangxiao joined
03:53 <thang1> Or you can write addition as (all objects 'a' that implement the Number interface) => a + a = a
03:54 <thang1> and voila, every type you ever define for the rest of your life just needs to implement Number and you get addition for /free/
03:54 <biotty> sorry i have a question. if you have addStuff = do a <- (*2) b <- (+10) return (a+b)
03:54 <biotty> then, how should i think about the a and b. what are they?
03:55 <jle`> biotty: in that case, addStuff :: Num a => a -> a
03:55 <biotty> what are the pure a and b in there?
03:55 <jle`> biotty: 'a' and 'b' are the result of applying (*2) to whatever input you call addStuff with
03:55 <thang1> so a and b can be anything that implements "Num"
03:55 <jle`> biotty: so if you call `addStuff 11`, then a is 22 and b is 21
03:55 <begriffs> DrMentats: oh yeah...of course! thanks.
03:55 <jle`> if you call `addStuff 3`, then a is 6 and b is 13
03:56 <biotty> i see. so for the function monad, do means we're inside a function kind of
03:56 biglambda joined
03:56 <DrMentats> begriffs: you may need to trim the quotes from both sides of the resulting string though
03:56 <thang1> sort of. This is where the "monads are burritos" nonsense comes from
03:57 <jle`> biotty: yea,h you're inside a world that's "awaiting" an input, kinda
03:57 <begriffs> I was adding those outside quotes before, so I just removed that part of the code.
03:57 <jle`> you're describing what you'd do with an input if you got it
03:57 steeze joined
03:57 <biotty> not far from a future
03:57 <jle`> like, if i got an input, i'd multiply it by 2 and call it 'a'. i'd also add 10 to it and call it 'b'. and the final reply will be a+b
03:58 <biotty> by the way, is haskell, like ghc, running thunks on different threads?
03:58 darjeeling_ joined
03:58 permagreen joined
03:59 fosterite joined
03:59 <jle`> i don't think it evaluate thunks in different threads by default
03:59 splanch joined
03:59 fosterite joined
03:59 <ChaiTRex> > let addStuff = do { a <- (*25); b <- (+13); return (a + b) } in addStuff 5
03:59 <lambdabot> 143
04:00 <biotty> would be a good leverage to exploit purity to get parallelism for free, that other languages struggle with
04:00 <thang1> biotty: Haskell already exploits purity very strongly to get concurrency
04:00 <thang1> (which is not the same as parllelism)
04:00 <jle`> not implicitly, though
04:00 <biotty> ok, not sure on my terminology with prallelism.
04:00 jer1 joined
04:00 <jle`> apparently implicit concurrency is trickier than what it might seem to be
04:01 <thang1> Immutable gets you concurrency much easier
04:01 <jle`> haskell's really good at explicit and dataflow concurrency
04:01 <jle`> and parallelism
04:01 <thang1> Immutable doesn't get you parallelism easier, it lets you refactor code more aggressively to make it parallel, but this depends on a fancy compiler.
04:02 <biotty> so, for a composed mathematical calculation, with composed separate outputs, stuff does not get computed in different threads i guess.
04:02 <thang1> Functional programming is more declarative and the more declarative your code is the less it expresses to a compiler "how" to do things and more "what" to do, so the compiler has more freedom to parallelize. This can be done with mutable or immutable stuff
04:02 <biotty> or can i start ghc with a j-factor or alike?
04:02 WhiskyRyan joined
04:03 <jle`> biotty: well, if you compose them linearly, there isn't much room for parallelism. but it's useful when you have parallel data dependencies. ghc just doesn't do it implicitly/automatically
04:03 <jle`> but it's very easy to do it explicitly
04:03 <biotty> sorry about "composed separate". i mean, if there are separate mathematical tasks
04:03 <biotty> s/mathematical/pure/
04:03 <pacak> How would you go about debugging "hGetContents: illegal operation (delayed read on closed handle))" that pops up very randomly considering you don't even use Handles?
04:04 <biotty> is there a thread monad
04:04 <thang1> https://downloads.haskell.org/~ghc/7.0.3/docs/html/users_guide/lang-parallel.html biotty
04:04 Costar joined
04:04 <thang1> tl;dr is link the program with -threaded, then run it with the RTS -N option
04:05 <jle`> pacak: readFile etc. all use file handles
04:05 <jle`> anything that works with files or the disk uses file handles
04:06 <jle`> what you gave sounds a lot like a complication with lazy IO
04:06 watabou joined
04:06 <pacak> jle`: I mean not using them directly. Isn't it supposed to be keept open until there are references to computation that can read more stuff from the file?
04:06 <pacak> s/until/while/
04:06 <jle`> the picture is complicated with lazy IO
04:06 JeanCarloMachado joined
04:07 <jle`> GHC tries to guess when you're done with the handle but it often guesses wrong except in the extreme simple cases
04:07 <biotty> my question about "thread monad" is really awkward but there's the IO monad ...
04:07 ryantrinkle left
04:07 <pacak> jle`: I know that it's lazy IO to blame, I'm curious how to debug this stuff.
04:07 <jle`> biotty: there's Par, a pure parallelism monad
04:08 <jle`> check out http://chimera.labs.oreilly.com/books/1230000000929/index.html :)
04:08 <ReinH> There's also a free book on parallel and concurrent programming in Haskell
04:08 <ReinH> yes that
04:08 shayan_ joined
04:08 <jle`> pacak: find out where you're using lazy IO
04:08 <jle`> and switch to strict IO
04:08 <jle`> hehe
04:09 haasn joined
04:09 rkazak joined
04:10 <pacak> I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.
04:10 <jle`> but in general it's difficult to control how Lazy IO executes except in the extreme simple toy cases
04:10 <thang1> jle`: step 1. Draw circle. Step 2. Draw rest of owl
04:10 <pacak> I guess that works.
04:10 aarvar joined
04:11 <jle`> one simple hack would be to use evaluate to make sure things are being parsed/read when you think they are
04:11 <jle`> evaluate w/ deepseq
04:12 <jle`> that can some some simple issues
04:12 <pacak> jle`: The problem is that shake uses lazy io all over the place.
04:12 <pacak> readFile' :: FilePath -> Action String
04:12 <pacak> readFile' x = need [x] >> liftIO (readFile x)
04:13 machinedgod joined
04:13 <jle`> one thing that can happen is that you do an operation in file contents to produce a value, but you don't use the value until after the handle is closed
04:13 <pacak> I'm pretty sure it can use some pounding...
04:13 <jle`> so immediately forcing the value instead of a let binding fixes that
04:13 <jle`> but yeah it's hard to say exactly without seeing code
04:14 <pacak> readFile' x = need [x] >> liftIO (readFile x >>= v -> length v `seq` return v)
04:14 <pacak> So this.
04:14 jer1 joined
04:14 <pacak> :(
04:14 <pacak> jle`: It's not even my code :)
04:14 JeanCarloMachado joined
04:14 <jle`> you can make some changes on your end maybe
04:15 connrs joined
04:16 louispan joined
04:17 <pacak> Yes, decorate every read operation with force...
04:17 takle joined
04:17 <pacak> Or replicate a bug and submit a bugreport.
04:18 georgeedward joined
04:22 drcode joined
04:24 alien8 joined
04:24 vlatkoB joined
04:26 eacameron joined
04:27 robertkennedy joined
04:29 <thang1> Is there any work in implementing a dynamic GC in Haskell that can switch between thorouput prioritizing and latency prioritizing?
04:29 blym joined
04:30 JeanCarloMachado joined
04:32 Swizec joined
04:33 eklavya joined
04:34 takle joined
04:35 zcourts joined
04:35 LuckyRawApe joined
04:37 <thang1> ahh okay, Haskell's GC uses the same collection algorithm in all of its generations
04:39 tromp joined
04:39 blym_ joined
04:39 leat joined
04:40 Argue_ joined
04:42 takle joined
04:43 SeMas joined
04:45 JeanCarloMachado joined
04:46 mrkgnao joined
04:46 mniip joined
04:48 robatosan joined
04:48 begriffs joined
04:49 mbuf joined
04:50 andyhuzhill joined
04:50 takle joined
04:51 hegemoOn1 joined
04:55 <adarqui> anyone use haskell-vim-now? any idea how to switch it 'off' completely for .go files for example .. want to use vimgo for that
04:55 mmachenry joined
04:56 jer1 joined
04:58 watabou joined
04:58 <clever> thang1: https://making.pusher.com/latency-working-set-ghc-gc-pick-two/
04:59 JeanCarloMachado joined
05:01 n1 joined
05:05 andyhuzhill1 joined
05:05 blym_ joined
05:06 v0latil3 joined
05:07 dec0n joined
05:08 fluffystub joined
05:08 systadmin joined
05:09 takle joined
05:09 andyhuzhill1 joined
05:09 JeanCarloMachado joined
05:14 jer1 joined
05:14 osa1 joined
05:14 osa1 joined
05:14 machinedgod joined
05:15 albel727 joined
05:16 splanch_ joined
05:17 takle joined
05:17 uuplusu joined
05:18 splanch__ joined
05:18 slemonide joined
05:19 WhiskyRyan joined
05:19 splanc___ joined
05:21 dm3 joined
05:22 wow12321 joined
05:22 <wow12321> anyone here
05:22 JeanCarloMachado joined
05:22 HelpSeeker joined
05:23 <pacak> wow: Your lack of patience disturbs me.
05:24 albel727 joined
05:24 <HelpSeeker> morning everyone, i am looking for someone preferably german-speaking to give me a hint in a task i am given. :-)
05:25 soniku joined
05:25 robatosan joined
05:25 <suzu> tell us about your task
05:27 louispan joined
05:27 <pacak> Preferably in English :)
05:27 BartAdv joined
05:28 <HelpSeeker> I summed it up here with an example: https://pastebin.com/HKtZPf8n
05:28 <pacak> the first value of each tuple not being > 3
05:29 <pacak> :t all (<3)
05:29 <lambdabot> (Num a, Ord a, Foldable t) => t a -> Bool
05:29 <pacak> if it's 0, then the second value has to be 0 aswell
05:29 albel727 joined
05:30 <pacak> :t \(a, b) -> a == 0 && b == 0 || a /= 0
05:30 <lambdabot> (Num a, Num a1, Eq a, Eq a1) => (a1, a) -> Bool
05:30 jgertm joined
05:30 <jle`> pacak: what a lovely operator
05:30 <pacak> :t all ((<3) . fst)
05:30 <lambdabot> (Num a, Ord a, Foldable t) => t (a, b) -> Bool
05:31 <pacak> :t and
05:31 <lambdabot> Foldable t => t Bool -> Bool
05:31 <pacak> :t all
05:31 <lambdabot> Foldable t => (a -> Bool) -> t a -> Bool
05:31 <pacak> Hmmm...
05:31 louispan joined
05:31 <pacak> :t all (\(a, b) -> a < 3 && (a == 0 && b == 0 || a /= 0)
05:32 <lambdabot> error:
05:32 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
05:32 <pacak> :t all (\(a, b) -> a < 3 && (a == 0 && b == 0 || a /= 0))
05:32 <lambdabot> (Num a, Num a1, Eq a, Ord a1, Foldable t) => t (a1, a) -> Bool
05:32 <pacak> > all (\(a, b) -> a < 3 && (a == 0 && b == 0 || a /= 0)) [((3,20),(3,20),(3,20)), ((3,20),(3,19),(2,25)), ((3,19),(3,19),(3,19)),         ((3,20),(3,19),(2,25)), ((2,25),(2,25),(2,25))]
05:32 <lambdabot> error:
05:32 <lambdabot> • Couldn't match expected type ‘(Integer, Integer)’
05:32 <lambdabot> with actual type ‘((Integer, Integer), (Integer, Integer),
05:32 <pacak> o_O
05:32 <pacak> Ugh, those are pairs inside of 3 tuples...
05:33 <pacak> HelpSeeker: How?
05:33 <HelpSeeker> ? :(
05:33 <jle`> why isn't there a Functor instance for 3- and 4- etc. tuples?
05:34 <jle`> and Applicative/Foldable/Traversable/Monad/etc.
05:34 Ford_Prefect joined
05:34 Ford_Prefect joined
05:35 <pacak> HelpSeeker: Your task description says nothing about outer tuples
05:35 jer1 joined
05:36 <HelpSeeker> what do you mean
05:36 <pacak> Or I don't understand the problem.
05:36 <HelpSeeker> its basically a darts game
05:36 sleffy joined
05:36 <Axman6> jer1: see the recent duscission on the... -libraries mailing list I think it was. Many people advocate strongly for having them, and some people say it makes life harder for newcomers
05:36 <Axman6> uh, jle`
05:37 <HelpSeeker> 3 throws per player
05:37 <pacak> jle`: Can be useful. Merge requests are accepted. With that in place it can result in even more confusing results :)
05:37 <pacak> > length (1,2,3)
05:37 <lambdabot> error:
05:37 <lambdabot> • No instance for (Foldable ((,,) t0 t1))
05:37 <lambdabot> arising from a use of ‘length’
05:37 v0latil3 joined
05:37 <HelpSeeker> (3,20) meaning triple 20 on the first one
05:37 louispan joined
05:37 <thang1> I'm of the opinion that if we have (,) we should have ( , ... ,) where you can have n number of , inside a generic n-tuple
05:37 JeanCarloMachado joined
05:37 <HelpSeeker> and after 3 throws it's the next players turn
05:38 <thang1> makes no sense to stop at (,) and go "that's it! We're done! Wrap it up here, folks, no more needed"
05:38 jhrcek joined
05:38 mda1 joined
05:38 <Axman6> yeah, it's nonsense to not have them
05:38 <pacak> thang1: up to 62-tuples? :)
05:38 <jle`> Axman6: that's fair i suppose
05:38 <jle`> i wouldn't ever use the Functor or Foldable instance
05:38 <jle`> but the Applicative, Traversable, Monad instances are useful
05:39 takle joined
05:39 <Axman6> but what if a beginner has to learn something! that would be horrible!
05:40 <jle`> Traversable instance might be done away with if we had Bitraversable in base
05:40 <pacak> jle`: There are tuples up to 62-tuples that means adding _a crapton_ of new instances. That will most likely affect compilation time
05:40 <thang1> pffh, a beginner already has to learn that length (,) is always going to be 1
05:40 <Axman6> exactly
05:40 aarvar joined
05:40 <jle`> i don't think that affects compilation time
05:40 <thang1> pacak: Idk, I feel like there's a way to recursively define n-tuples
05:41 <jle`> some lbiraries do it using TH
05:41 <Axman6> I think the whole argument is just crazy, there is an obvious right thing to do which makes the language more usable, and learning why length <tuple> == 1 must be the case is very valuable
05:41 <jle`> but n-tuples aren't really meant to be worked with inductively
05:42 <pacak> thang1: Sure, (a,b,c) is isomorphic to (a, (b,c)), but on run time it will result in a bunch of indirections
05:42 fizruk joined
05:42 <thang1> Base case: Tuples are a container that hold some values (a,b)
05:42 <thang1> you can do stuff to b, you can do stuff to a (sorta)
05:42 <thang1> Inductive step: Now... imagine there are numbers higher than two
05:42 <jle`> you can think of them that way, and some libraries do. but the tuple type in haskell isn't structured inductively like that
05:42 <Axman6> (you probably want to define them as being isomorphic to ((a,b),c) I think
05:42 <Axman6> )
05:42 <thang1> Suddenly, the world expands. Heavens open, angels cry tears of joy
05:43 <jle`> the typical approach is as a monoid with (,) and () as identity
05:43 <thang1> ... Behold: ( , , )
05:43 reggie_ joined
05:43 <pacak> Axman6: It's still isomorphic.
05:43 <Axman6> :o
05:43 argent0 joined
05:43 <thang1> Axman6: merely an implementation detail /s
05:43 <Axman6> pacak: sure, but it makes the induction easier I think
05:43 <jle`> but it isn't that hard to make an actual inductive tuple type
05:43 dec0n joined
05:43 ali_bush joined
05:43 ali_bush joined
05:43 <jle`> in haskell
05:43 <pacak> But for that you'll pay either on compile time or on run time
05:44 <thang1> clever: that is actually the very article that prompted my GC question
05:44 <clever> heh
05:45 <pacak> Axman6: Easier - yes, but if it suddenly takes 10 times longer to compile or it runs 10 times slower - I don't want it.
05:45 WhiskyRyan joined
05:45 <pacak> Also behold - generics!
05:46 <Axman6> oh I agree, you definitely want tuples to actually be product types with n elements, not a list at runtime
05:46 <pacak> So you pay on compile time.
05:46 danvet joined
05:46 <Axman6> yeah
05:47 <Axman6> Ideally you pay once at the compile time of GHC
05:47 <Axman6> +base
05:47 <cocreature> being able to define tuples inductively while avoiding indirections at runtime is one of the few things I envy c++ for
05:47 <thang1> Still, I don't really see how generic n-tuples would literally explode the compile time of GHC
05:47 <thang1> cocreature: is that because of templates?
05:47 <pacak> ghc will need to keep all this stuff around when compiles code - just in case you want to get length of 62-tuple
05:47 JeanCarloMachado joined
05:48 <pacak> so you'll have to pay on compile time for all the things.
05:49 louispan joined
05:49 <thang1> I guess I'm just not really seeing how going from 1 to 62 is going to make a giant difference :p
05:49 <pacak> Let'
05:50 latino31 joined
05:50 <pacak> Let's see... Functor, Foldabe, Applicative, Traversable, Monad with 2-3+ methods in each
05:50 <pacak> multiply that by 62
05:50 <thang1> https://wiki.haskell.org/Accessible_layout_proposal also this is the kinda stupid insanity I like to see
05:50 <pacak> Thus much stuff you'll have to keep in memory. All the time.
05:50 edsko joined
05:51 <thang1> It's got everything. 1) ugly hack due to backwards compatibility. 2) bikeshedding to make the language prettier to look at. 3) More confusing weird crap for beginners motivated by said backwards compatibility nonsense
05:52 mstruebing joined
05:53 cur8or joined
05:53 <thang1> But with Functor, Foldable, Applicative, Traversable, etc... you don't have to define different instances for lists of different sizes
05:53 <thang1> [,] = [,,] = [,,,] = [, ... ,] as far as writing instances goes
05:53 <thang1> write it once for the list container, it works on lists of all sizes
05:54 <pacak> thang1: Not really. There are different pattern matches all over the place
05:54 <cocreature> thang1: sort of, it’s obviously a template type but that alone is not sufficient. iirc most implementations these days abuse multiple inheritance where they inherit from "TupleElement<index, value_type>" and then getting the nth element is just a cast
05:54 <pacak> > fmap show (1,2)
05:54 <lambdabot> (1,"2")
05:54 <pacak> this needs to pattern match against (1,x)
05:54 slemonide joined
05:55 rushi joined
05:55 blym_ joined
05:55 jbgi joined
05:55 JeanCarloMachado joined
05:55 insitu joined
05:56 jer1 joined
05:56 <thang1> cocreature: most implementations of n-tuples? Or most implementations of foldable/etc instances?
05:56 <suzu> > (\(1,x) -> x) (1,5)
05:56 <lambdabot> 5
05:56 <suzu> > (\(1,x) -> x) (8,5)
05:56 augur joined
05:56 <lambdabot> *Exception: <interactive>:3:2-12: Non-exhaustive patterns in lambda
05:56 brynedwardz joined
05:57 <suzu> > (\(1,x) -> x) (1,(5, undefined))
05:57 <lambdabot> (5,*Exception: Prelude.undefined
05:57 <Cale> thang1: That's because functions on lists are recursively defined to work that way. Code for tuples of different sizes is physically different for each size of tuple.
05:58 urodna joined
05:58 <Cale> (you can't just run code which was compiled for triples with 5-tuples and expect anything to work)
05:58 <thang1> Cale: True. I guess I just don't really see why it necessairly has to be that way by default. If you want to write a magic function that works differnt on triples than 5-tuples, sure, why not. But generic functions should be generic
05:58 vektorweg1 joined
05:58 <thang1> fmap is generic, so to me it seems like you should only need one fmap instance for any n-tuple, in theory
05:59 <Cale> If tuples were more list-like in memory, then perhaps you could act on them generically.
06:00 plot joined
06:00 machinedgod joined
06:01 <jle`> thang1: in haskell, tuples are just unrelated types
06:01 <jle`> like data T1 a = T1 a
06:01 <jle`> data T2 a b = T2 a b
06:01 <jle`> data T3 a b c = T3 a b c
06:01 <jle`> can you write a generlic fmap for all of those?
06:02 <jle`> (you can with ghc generics, but)
06:02 <Cale> Also, it's a bit of a moot point, since anything larger than a pair is hardly ever used.
06:02 <Cale> Once you get beyond pairs, you should probably write your own data type.
06:02 hurkan joined
06:02 <deank> lens provides a generic way of accessing tuples, I just can't recall the name of the lens
06:02 <ReinH> you can get arbitrarily large tuples lisp style if you want
06:03 <jle`> GHC.Generics gives you a generic way of accessing tuples
06:03 <thang1> It still feels pretty ugly to me that nobody ever uses more than 2, that so much stuff is hard coded into 2,3,X-tuple functions, and so on
06:03 dm3 joined
06:03 <jle`> ideally no things are hard-coded into 3+ tuples
06:03 <jle`> using 3+ tuples is sort of bad practice
06:03 <ReinH> I can access arbitrarily large tuples with fst and snd ;)
06:03 <ReinH> I just build my tuples differently
06:03 <Cale> thang1: It makes sense. It'd be far *more* ugly if people did use larger tuples.
06:04 rkazak joined
06:04 <Cale> thang1: You have to remember what the tuple components mean. It's much better to define a record type and name them, usually.
06:04 eatman joined
06:04 lambdaman joined
06:05 xcin left
06:05 takle joined
06:05 <ReinH> do you have a moment to talk about cdddaddadr
06:06 <deank> > view _1 (10, 20)
06:06 <lambdabot> 10
06:06 <deank> > view _1 (10, 20, 30)
06:06 <lambdabot> 10
06:06 <thang1> lol
06:06 <jle`> yeah, _1 doesn't quite do that using inductive definitions
06:06 <Cale> Yeah, that's just a bunch of type classes with a ton of instances
06:06 <jle`> it just makes a typeclass that tuples are instances of
06:06 <Cale> :t _1
06:06 <lambdabot> (Functor f, Field1 s t a b) => (a -> f b) -> s -> f t
06:06 <jle`> and makes instances for bunches of tuples
06:07 <pacak> :t _62
06:07 <lambdabot> error:
06:07 <lambdabot> • Found hole: _62 :: t
06:07 <lambdabot> Where: ‘t’ is a rigid type variable bound by
06:07 <pacak> Nope.
06:07 <ReinH> let cdddaddadr = view (_2._2._2._1._2._2._1._2)
06:07 <Cale> iirc the highest is _9?
06:07 <Cale> :t _9
06:07 <lambdabot> (Functor f, Field9 s t a b) => (a -> f b) -> s -> f t
06:07 <deank> if you are using 10 element tuple you have bigger problems than _10 not being defined (:
06:07 <thang1> lol true
06:08 <cocreature> thang1: most implementations of std::tuple in c++
06:08 <Cale> Perhaps a complete lack of taste being foremost among them ;)
06:08 <Axman6> ReinH++
06:09 <ReinH> You can write lisp in any language if you try hard enough
06:09 matthewbauer joined
06:10 JeanCarloMachado joined
06:10 <Axman6> you've reminded me of: https://raw.githubusercontent.com/mxswd/flip-plus/master/Control/FlipPlus.hs
06:10 <thang1> oh wow
06:10 <ReinH> I notice that most references only go up to cddddr. They are weak.
06:11 fowlslegs joined
06:11 <jle`> beautiful
06:11 xall joined
06:11 <ReinH> yes this is significantly better
06:11 <Cale> such utility
06:11 robertkennedy joined
06:11 <ReinH> very mnemonic
06:12 <jle`> i ... actually see the pattern now
06:12 <ReinH> free your mind
06:12 lambdaman joined
06:12 <thang1> Drink the koolaid
06:13 <ReinH> that's actually a pretty awfully morbid reference if you stop and think about it
06:13 <ReinH> I recommend not stopping and thinking about anything
06:13 <jle`> tried uploading it to lpaste
06:13 <jle`> but it's too large
06:13 <ReinH> hahaha lpaste is weak
06:13 <jle`> i deserved this
06:13 <ReinH> it can't handle the magnificence
06:13 <ReinH> it is unworthy
06:14 zeroed joined
06:14 zeroed joined
06:15 plot joined
06:15 <Cale> https://hackage.haskell.org/package/these-0.7.3/docs/Control-Monad-Chronicle.html
06:15 <thang1> Okay, so records are what you want instead of n-tuples...
06:15 connrs joined
06:16 <Cale> yeah, generally
06:16 <jle`> @let instance Field1 [a] [b] a b where _1 = ix 1
06:16 <lambdabot> .L.hs:173:14: error:
06:16 <lambdabot> • Couldn't match type ‘a’ with ‘b’
06:16 <lambdabot> ‘a’ is a rigid type variable bound by
06:16 <jle`> thang1: yes lol
06:16 JeanCarloMachado joined
06:16 <thang1> What do people actually legitimately use (,) tuples for, then?
06:16 <jle`> when they're too lazy to create a new data type
06:16 <thang1> I'm used to using and thinking about tuples as basically heterogenius lists
06:16 <jle`> you can think of (,) as an anonymous product
06:16 jer1 joined
06:16 santoast joined
06:17 <thang1> ahh, okay
06:17 <jle`> just like how lambda (\x -> ...) are anonymous functions
06:17 <jle`> you use lambdas when you're too lazy to name the function
06:17 <Cale> thang1: I tend to think of (l,x) as being like a labelled container with a single value (x), and a label (l)
06:17 <jle`> you use tuples when you're too lazy to name your product
06:17 baldrick1 joined
06:18 <ReinH> Yeah, that's the (a,) functor/foldable/traversable
06:18 <Cale> All the instances are defined in such a way as to support that (and really, that's kind of forced)
06:18 <jle`> and Applicative/Monad too
06:18 <santoast> I'm am looking at the definition for unzip and it says that it's > unzip' = foldr (\(a,b) ~(as,bs) -> (a:as,b:bs)) ([],[]) ....my question is what does that (~) "tilda" symbol do in the lambda expression?
06:18 <Cale> > fmap (\x -> 10*x) ("hello", 5)
06:18 <lambdabot> ("hello",50)
06:18 <ReinH> jle`: yeah I just got tired of typing the :p
06:18 <jle`> santoast: look up lazy or irrefutable pattern matches
06:18 <ReinH> *them
06:18 <santoast> okay
06:18 <jle`> it tells ghc to don't check if the (,) constructor was really used
06:18 <jle`> and go down that case immediately
06:18 <jle`> without verifying the pattern
06:19 <Cale> santoast: It makes the pattern lazy -- it will match immediately without the pair being evaluated, and only when as and bs are used will it evaluate that argument.
06:19 tromp joined
06:19 <Cale> With pairs, it's pretty safe
06:19 <santoast> ah okay! thank you :)
06:19 <thang1> So when do you actually use lazy matches? Sweet talking the compiler into more efficient code?
06:19 <Cale> With types that have multiple constructors, it can result in exceptions if the pattern didn't really match after all
06:20 <thang1> Cale: that's a good way to think about tuples in haskell, thanks.
06:20 <jle`> well, sometimes you don't want to force the resolution of the pattern
06:20 bigos_ joined
06:20 <Cale> thang1: It also fits in with Map
06:21 <Cale> :t fromList
06:21 <lambdabot> IsList l => [Item l] -> l
06:21 systemfault joined
06:21 micmus joined
06:21 <Cale> :t M.fromList
06:21 <lambdabot> Ord k => [(k, a)] -> M.Map k a
06:21 <Cale> there we go
06:21 <Cale> So, you build a Map out of a bunch of pairs, each of which has a key and a value
06:21 paolino joined
06:21 <thang1> ooh neat. I see, now. So disregard entirely any mathematical concept of tuple, and think of them only as (key,val) pairs
06:22 <ReinH> No, they're useful as tuples too
06:22 daishan left
06:22 <Cale> They are pairs, it's just that there's a natural bias to the order in which the components come, which is induced by the way that type classes work
06:22 <thang1> It works for my brain better if I think of them exclusively as (label, data) pairs
06:23 <ReinH> well, that's unnecessarily limiting yourself
06:23 baldrick2 joined
06:23 <ReinH> products are nice to have around
06:23 <Cale> Not everything out there will follow this nice pattern unfortunately
06:23 <Cale> :t runState
06:23 <lambdabot> State s a -> s -> (a, s)
06:23 <Cale> That ought to be (s,a)
06:24 <thang1> My brain will autoamtically generify the concept after a bit, but for now it's more accurate to think of it as (k,v) rather than "heterogenius list of values that got limited to 2 because the language wasn't designed cleverly enough in the first place"
06:24 <ReinH> eh, that's not what anyone is suggesting?
06:24 rushi left
06:25 <thang1> I know. Right now those are the two definitions of tuple floating in my head. I'll pick the more correct one and let the even more correct definition absorb over time through osmosis and what not
06:26 louispan joined
06:26 <Cale> I dunno, in mathematics, when you form a Cartesian product of a bunch of sets, it tends to only specify those tuples of a particular size and shape, and if you define a function out of such a product, it doesn't automatically work for other Cartesian products :)
06:26 <ReinH> > [(a,b) | a <- "hello", b <- "world"] -- it's nice to have products
06:26 <lambdabot> [('h','w'),('h','o'),('h','r'),('h','l'),('h','d'),('e','w'),('e','o'),('e',...
06:26 <Cale> There's a lot more freedom to define families of functions there though.
06:26 mmn80 joined
06:26 JeanCarloMachado joined
06:27 jer1 joined
06:27 augur joined
06:27 eacameron joined
06:27 <ReinH> if you think the tuple situation is bad, you should see what people get up to with indexed functor families.
06:27 <Cale> We don't have dependent types in Haskell, so you can't easily say "oh, let the type depend on this number which is a separate argument to the function"
06:28 <thang1> Right, and I'm more used to that freedom, so rather than trip myself up and get frustrated at a lack of a very specific type of freedom, I'd rather artifically restrict myself in one area and increase my brain's ability for thinking in a different pattern (namely creating record types)
06:28 <Cale> That's fair, I think
06:28 <suzu> > do { a <- "hello"; b <- "world"; return [a,b]; }
06:28 <lambdabot> ["hw","ho","hr","hl","hd","ew","eo","er","el","ed","lw","lo","lr","ll","ld",...
06:29 <Cale> thang1: Another thing you can imagine is that tuples are just very unopinionated, distinct, record types
06:29 xtreak joined
06:29 <suzu> > sequenceM ["hello", "world"]
06:29 <lambdabot> error:
06:29 <lambdabot> • Variable not in scope: sequenceM :: [[Char]] -> t
06:29 <lambdabot> • Perhaps you meant one of these:
06:29 <suzu> wut
06:29 <Cale> Sometimes, if you just have two things you need to produce as the result of a function, it isn't *quite* worth it to define a new type
06:29 <suzu> oops
06:29 <ReinH> sequence or sequenceA, there is no sequenceM
06:29 <thang1> I do it all the time, it's great for learning things. Pick the simplest heuristic that is a strict subset of the "real" idea, then explore as much as possible. Your brain's automatic refining of heuristics will converge to the correct and nuanced concept; additionally, you'll learn how to think in different patterns easier
06:30 <suzu> > sequence ["hello", "world"]
06:30 <suzu> thats the one
06:30 <lambdabot> ["hw","ho","hr","hl","hd","ew","eo","er","el","ed","lw","lo","lr","ll","ld",...
06:30 <Cale> thang1: But as soon as you have more than 3, it's quite clear that you should be defining some type to organise the various parts of the result of your function.
06:30 <paolino> > sequence . sequence $ ["hel","wo"]
06:30 <lambdabot> ["hheell","hheelo","hheewl","hheewo","hheoll","hheolo","hheowl","hheowo","hh...
06:31 <thang1> Right, just like you want to abstract out modular inner functions as quickly as possible
06:31 ubsan_ joined
06:31 takle joined
06:32 <jle`> thang1: the Functor/Foldable/Applicative/etc. instances treat them as (k,v) pairs, but that's just those specific instances
06:32 <paolino> also (a,(b,(c,.... are useful sometimes
06:32 <thang1> sometimes :p
06:32 <jle`> thang1: just like how the Applicative instance treats lists like "possible values"
06:32 <jle`> thang1: but that's just that particular instance's semantics
06:32 <jle`> lists are also useful for other things, as well
06:33 <jle`> like, holding things, or being streaming data sources
06:33 JeanCarloMachado joined
06:33 <ReinH> > iterate sequence ["hel", "wo"]
06:33 <lambdabot> [["hel","wo"],["hw","ho","ew","eo","lw","lo"],["hheell","hheelo","hheewl","h...
06:33 <thang1> Right, that's a cool way to think about those
06:34 spacecadetbrown joined
06:34 louispan joined
06:34 xall_ joined
06:35 <Cale> haha, iterate sequence
06:35 <thang1> Now, dumb category theory question. Are Functor,Applicative,etc all categories in of themselves? I know you don't need to define a class that's an actual category in CT, but I'm assuming all of the "standard" ones have very strong CT theory behind them?
06:36 <Cale> Well, there is a category of all functors and natural transformations
06:36 <Cale> (between a given pair of categories, in this case, they'd be the endofunctors Hask -> Hask)
06:36 dm3 joined
06:36 zcourts joined
06:37 <Cale> and then you can define a notion of which natural transformations are homomorphisms of applicative functors or monads, and define suitable subcategories of those
06:37 nickolay joined
06:37 <jchia> Is anyone encountering a problem where after running a program compiled with ghc, the terminal gets messed up so that backspace does not erase buffered input? In other words, while sleep 1000 is running, if I presse 'a' followed by backspace, the backspace does not erase the a but shows up as '^?' on the terminal.
06:37 <jchia> The problem goes away only after I run reset.
06:37 <ReinH> Hmm... The question "is Applicative a category?" is probably either a deep question about monoidal functors or a misunderstanding of what a category is.
06:38 <ReinH> jchia: ghc or ghci?
06:38 <Cale> Or the shallow question that I answered :)
06:38 <jchia> ReinH: ghc. i haven't tried ghci
06:38 <thang1> neat
06:38 <Cale> The type class itself isn't a category
06:38 JeanCarloMachado joined
06:38 guiben joined
06:39 <ReinH> jchia: well, your program could be printing escapes to stdout that could cause that
06:39 <thang1> I figured, it didn't seem quite right for the type class to be one
06:39 <ReinH> but ghc itself wouldn't
06:39 <Cale> It's just that the functors which are instances of it can be arranged as the objects of a category -- which isn't saying a whole lot, most things can be.
06:39 zcourts_ joined
06:39 <jchia> ReinH: No, my main is just 'pure ()'.
06:39 <paolino> there i a commuting graph in Hask -> Hask for each one of them ?
06:40 <jchia> ReinH: Maybe it's something that the runtime system does, if that counts as 'my program'.
06:40 <ReinH> jchia: how are you running it?
06:40 <thang1> So type classes bear a passing resemblance to the categories and are related to categorial concepts, but there's not much outside of that?
06:40 <ReinH> type classes do not resemble categories per se. They are sometimes used to describe things that resemble categories.
06:40 <ReinH> Like functors.
06:41 cranej joined
06:42 <thang1> Right. And categories offer useful ways to speak generically and broadly about concepts, so well designed type classes often end up resembling categories but merely out of coincidence than any deeper necessity or meaning
06:42 <thang1> (if I'm understanding everything right)
06:42 <ReinH> Well, category theory is the abstract algebra of abstract functions. Type classes define a collection of functions.
06:42 <Cale> Well, the type class doesn't do that on its own -- we have to put in a bunch of stuff.
06:43 <ReinH> When you do well-behaved things with functions, there's often a way to make sene of it categorically
06:43 <Cale> It's not those functions though...
06:43 <Cale> heh
06:43 <Cale> Natural transformations between functors f and g are roughly polymorphic functions of type forall a. f a -> g a
06:44 <jchia> ReinH: http://lpaste.net/355217
06:44 lijy joined
06:44 <ReinH> jchia: well that's odd
06:44 alfredo joined
06:44 plot joined
06:45 ertes-w joined
06:45 <Cale> They're really families of functions eta_X :: F X -> G X for each type X, such that for any function h :: X -> Y, you have fmap h . eta_X = eta_Y . fmap h
06:46 <Cale> and those are then the arrows in your category of functors
06:46 ventonegro joined
06:46 <jchia> ReinH: Well, GHC is associated with libtinfo, which looks like something related to the terminal, so I suspect the runtime system is causing this.
06:46 <ReinH> I mean. I guess Show induces a slice category or something but it isn't very interesting.
06:47 <Cale> ah, okay, yeah, there's often a way to derive what the "obvious" sort of homomorphism would be for a given type class
06:47 guiben joined
06:47 JeanCarloMachado joined
06:49 <thang1> jchia: well
06:49 <jchia> ReinH: Turns out it's not my program. Turns out it stack itself.
06:49 <thang1> I just ran and compiled your test program on my computer. I have no sleep issues or backspace issues at all
06:49 blym_ joined
06:49 <ReinH> jchia: neat
06:49 Grisha joined
06:49 <jchia> ReinH: (stack which)
06:49 <thang1> I also used stack :p
06:50 <jchia> ReinH: I mean stack exec which
06:50 guiben_ joined
06:50 <ReinH> Cale: speaking of which, I'm trying to muddle my way through Jon Sterling's topos notes and oh my god
06:50 <ReinH> good thing I have Mac Lane's book lying around
06:50 <jchia> thang1: I'm using stack on Fedora 22. What about you?
06:51 <thang1> Arch linux
06:51 <* thang1> tips fedora, scratches neckbeard
06:51 <jchia> thang1: Let me try this on my Arch Linux later.
06:51 <thang1> I'm also using Protolude as the template
06:51 <ReinH> something something subobject classifier, something something Yoneda, and apparently now we have type theory.
06:51 <thang1> what version of stack and what resolver are you using? I'm using lts-8.13
06:52 watabou joined
06:52 <thang1> ReinH: type theory fascinates me
06:52 biglambda joined
06:52 <thang1> I've been going down a deep rabbit hole lately trying to connect stronger type theories like HoTT, Uniqueness Types, Dependent Types, etc., with logical programming with functional programming
06:54 <ReinH> Cale: he has a paragraph titled "Understanding Ω using Yoneda’s Lemma as a weapon"
06:55 Destol joined
06:55 augur joined
06:55 JeanCarloMachado joined
06:56 quchen joined
06:56 dm3 joined
06:56 <thang1> (cue "when you have a hammer..." quote)
06:56 jer1 joined
06:57 <ReinH> it's a pretty good hammer
06:57 <mrkgnao> ReinH: like, a loop space?
06:57 louispan joined
06:57 <ReinH> mrkgnao: which?
06:58 <ReinH> Oh, Ω
06:59 <ReinH> No, I think it's just a namespace collision on Ω
06:59 <jchia> thang1: stack 1.4.0, lts-8.12
06:59 Gloomy joined
06:59 <ReinH> unless there's some deeper connection I am unaware of
07:00 <thang1> jchia: weird. I used lts-8.13 but it shouldn't have done anything special
07:01 augur joined
07:01 <ReinH> mrkgnao: a subobject classifier is a generalization of the characteristic function for set membership.
07:01 <jchia> thang1: So 'stack exec which -- blah' doesn't mess up your terminal?
07:02 <thang1> Nope
07:02 dm3 joined
07:02 <thang1> I'm assuming at this point that you have a semi-decently customized terminal shell?
07:02 <jchia> thang1: OK, I'll try again later on my Arch Linux.
07:02 <thang1> open up sh and then try stack exec which -- blah
07:02 <jchia> thang1: Yeah, I think there's some customization.
07:03 <thang1> If my hypothesis is right, you have some weird color escaping going on that's messing with escape sequences
07:03 <jchia> thang1: Same problem in sh
07:04 <jchia> Does stack automatically clear out old files in ~/.stack/ and .stack-work/ that are used only by really old resolvers? (I suppose it doesn't.) Is there a reliable way to clear them out without messing things up for the latest resolver I'm using?
07:04 <thang1> weird... Can you reproduce the problem by not using stack exec which -- blah, but rather just running some arbritrary thing that will get you a very long line of text?
07:04 <thang1> jchia: stack installs are ideally idempotent
07:04 asthasr joined
07:04 <glguy> tonight I've been working on a module for describing how to extract fields from a configuration file, as well as how to generate documentation about that configuration file format that seems to be working well. http://lpaste.net/355216 there's an example at the top of some output from it. (this is the config language my client and other projects use)
07:04 takle joined
07:05 <thang1> So you can just nuke your entire ~/.stack directory
07:05 JeanCarloMachado joined
07:05 <thang1> and then build and install everything all over again. This time it'll only install what you actually use, of course
07:05 <ReinH> glguy: neat
07:06 <jchia> thang1: You mean like 'echo `for f in 1 2 3 4 5 6 7 8 9 10; do for g in 1 2 3 4 5 6 7 8 9 10; do echo abcdefghijklmnopk; done; done`'?
07:06 <jchia> thang1: If so, it doesn't repro
07:06 <thang1> Odd. It's most likely not a term escape sequence issue then
07:07 louispan joined
07:07 takuan joined
07:07 <thang1> (lines that are longer than the terminal width often cause breaking issues with color escape code)
07:07 <Maxdamantus> yes abcdefghijklmnopk | head -100
07:08 <thang1> I find it really odd that it's that one specific command
07:08 baldrick1 joined
07:09 <Myrl-saki> Bash? In a Haskell channel? I've seen everything.
07:09 insitu joined
07:09 <dysfun> yesterday someone wanted to generate bash in haskell
07:09 <jchia> Maxdamantus: yes , I did not know that I could use yes with arguments
07:10 <thang1> Well I'm trying to debug why terminal escape sequences aren't being interpreted right after someone runs a stack command, it's about as relevant as it gets
07:10 <Maxdamantus> Haven't you heard? GHC 9 is going to be rewritten in bash.
07:10 <dysfun> Maxdamantus: no, that's 'bashkell'. a whole new paradigm of development awaits
07:10 <ReinH> dysfun: they can use the bash monad.
07:10 <thang1> I thought it was going to just be one giant perl 5 regular expression?
07:11 <dysfun> well perl 5 res *are* turing complete...
07:11 panovia joined
07:11 xall_ joined
07:11 <ertes-w> Myrl-saki: it translates into: traverse_ putStrLn (do replicateM_ 2 [1..10]; pure "abcdefghijklmnopk")
07:11 <thang1> damn straight they are. Nothing says "I regret my life choices" by forcing regex to be able to parse html and validate email addresses
07:11 louispan joined
07:11 <Maxdamantus> jchia: if you're willing to assume bash, you might also be interested to know that you can just write `for ((x = 0; x < 100; x++)); do echo abcdefghijklmnopk; done`
07:11 freusque joined
07:12 <* dysfun> has pondered disproving "you can't safely parse html in regex" in turing-complete REs
07:12 <jchia> Maxdamantus: That's almost like C, except for the double parantheses
07:12 splanch joined
07:12 <ertes-w> dysfun: turing-complete REs? you mean like irrational natural numbers?
07:12 mjora7 joined
07:12 ogrady joined
07:12 <Maxdamantus> Yeah, the double parentheses indicate something C like in various contexts in bash.
07:13 <dysfun> ertes-w: perl allows the embedding of perl code
07:13 jer1 joined
07:13 <Maxdamantus> x=5; ((x++)); echo $((x*5 + 2))
07:13 <ertes-w> dysfun: sure, but the proposition is: "you can't safely parse HTML in *regex*" ;)
07:13 Itkovian joined
07:13 <thang1> Maxdamantus: ideally I'd like the forloop to append everything so you get one giant line of text, not 100 lines of text
07:13 <ertes-w> dysfun: perl regex can parse super-regular grammars
07:13 <dysfun> ertes-w: that perl code is totally in my regex
07:13 vlatkoB_ joined
07:14 <Maxdamantus> thang1: well, you can use `echo -n ..`
07:14 <dysfun> and actually you don't even need to go that far, they extended the regex engine to be much more powerful anyway
07:14 <ertes-w> dysfun: that's because "regex" has been highly overloaded
07:14 robkennedy joined
07:14 splanch_ joined
07:14 codesoup joined
07:14 ryxai joined
07:14 <thang1> of course you can. I always forget about that one
07:14 <Maxdamantus> If you're just looking for random input, I'd just do something like `tr -dc a-z </dev/urandom | head -c 10000`
07:14 <thang1> thanks
07:14 <dysfun> things i do not consider 'regex' include: posix regex, posix extended regex...
07:14 <ertes-w> dysfun: the original "regular expressions" can only parse regular grammars, hence the name
07:15 robkennedy joined
07:15 laz joined
07:15 <thang1> jchia: can you run that line of code that Maxdamantus gave and then try the sleep 100 thing?
07:15 <dysfun> are they regular? oh hell no, they don't even look it
07:15 <ertes-w> dysfun: much like most modern "relational databases" aren't really "relational" =)
07:15 <dysfun> i've taken to calling them 'pseudo-relational'
07:16 <thang1> Or you could call them disfunctional :p
07:16 <ReinH> ertes-w: haven't you heard, words don't mean things any more
07:16 <Maxdamantus> note though that the `tr` command above won't produce a newline on its own, so if you pipe it to something it might sit in a buffer forever.
07:16 splanch__ joined
07:17 <jchia> thang1: You mean the `tr ...`? No, it doesn't repro
07:17 <dysfun> still, i'm not convinced a proper relational database is 'better', as such than postgres
07:17 <thang1> But you can still do it with stack exec... ?
07:17 <thang1> I gotta admit, I'm stumped. Short of nuking your entire stack environment and reinstalling everything, I'm out of suggestions :p
07:18 <thang1> dysfun: I find relational databases to be really nice for things that are modeled really well with relationships
07:18 <ertes-w> ReinH: yeah, natural language is stupid… let's talk in holish
07:18 <thang1> But they feel like the OOP of databases. It's "THE" way to do things, so there's all this tons and tons of information about it and nobody ever bothered to ask why we even do things that way
07:19 <ertes-w> or perhaps some day we'll talk in hottish
07:19 <thang1> and it turns out that people like google, facebook, etc., and basically any super high performance high end "database" system is using stuff that looks literally nothing like a database
07:19 jutaro joined
07:20 <thang1> In fact, all of their data structures in general are just huge mashes of maps, graphs, weird crap sprinkled all over the place, caches out the wazoo, and so on. It's ridiculous, but wicked fast and way more powerful than any old school database
07:20 <ertes-w> thang1: recently someone got me really intrigued about mongodb, so i checked it out and did a few minor experiments… just about when it was going to get interesting, i found myself asking: "ok, how do i code a transaction?"
07:20 <ertes-w> 15 minutes later i went back to relational databases
07:20 tromp joined
07:20 <thang1> Yeah that pretty much sums up mongoDB for me, too
07:21 <thang1> "oh neat, this is so cool! Wait... it's useless? Really? Well that's a shame"
07:21 <ertes-w> i wouldn't go as far as to call it useless, but it's not much more than a fancy key/value store
07:22 <dyreshark> who needs correctness when you have efficiency?
07:22 robertkennedy joined
07:22 robertkennedy joined
07:22 <cocreature> just use /dev/null as a high-performance database
07:22 <thang1> Yeah, it's not useless, you just have to have a very good reason to use it.. Even then, there are some other databases out there that do what Mongo does but do it better (at least, it seemed that way last tiem I checked)
07:22 mekeor joined
07:23 <thang1> Garbage collector? Pffh, who needs that. Can't make garbage if your language can't do anything!
07:24 <dyreshark> if your app doesn't make garbage quickly, the OS can be your garbage collector
07:24 <dyreshark> just restart it when it runs out of memory
07:24 <ertes-w> now if you give me something like mongo that can do transactions (and doesn't hold all the data in RAM constantly, i.e. no acid-state), i'd probably use it =)
07:24 Durbley joined
07:24 <thang1> ertes-w: isn't that just postgress?
07:24 zeroed joined
07:24 mattyw joined
07:25 soniku joined
07:25 <ggVGc> dyreshark: or run new processes for each short term task
07:25 louispan joined
07:25 <dyreshark> true
07:26 <ertes-w> thang1: the ability to just dump arbitrary JSON and have it indexed for fast search is nice… i can see the appeal… also my application has a schema, i don't need a copy of it in the DB, because that only makes me write migration code…
07:26 <ertes-w> [incoming rant]
07:26 <dysfun> dyreshark: fast-staring microservices and unikernels
07:26 <dysfun> starting*
07:27 <ertes-w> anyway, this is getting way off-topic =)
07:27 <bartavelle> thang1, postgresql gives you the ability to just dump arbitrary json and have it indexed (sort of, only the top level keys of an object I think)
07:27 <bartavelle> erm
07:27 <dysfun> monads! applicatives! functor laws!
07:27 <bartavelle> that was for ertes-w
07:27 robertkennedy joined
07:27 indi_ joined
07:28 <dysfun> bartavelle: nope, arbitrary json operator expressions actually ("partial indexes")
07:28 takle joined
07:28 <thang1> That's the appeal of mongodb. It's all the benefits of a database without any of the hard work* (*not actually)
07:28 bvad joined
07:28 <bartavelle> dysfun, ah!
07:29 <thang1> But if you need a database and you're a startup and you want something semi function in 2 seconds and you're going through ultra rapid major functionality changing prototyping of data aggregation services...
07:29 <ertes-w> bartavelle: postgres has expression indices, yeah… not quite as convenient though
07:29 baldrick1 joined
07:29 <thang1> mongoDB is what you want in that case
07:29 <dysfun> but of course if you want them indexing, you have to write the indexing code. so you're back to 'looks like work'
07:29 <ertes-w> also i'm slowly moving toward doing most things with sqlite instead of postgres =)
07:30 <bartavelle> ertes-w, that's not really comparable though, "sqlite was designed to compete with fopen"
07:30 Durbley joined
07:30 <dysfun> most of us can't get away with sqlite, sadly
07:30 <ertes-w> bartavelle: yeah… it's a better fit for me in most cases
07:30 <ertes-w> i don't need concurrent access 99% of the time
07:31 <dysfun> why don't you just use acid-state then?
07:31 <bartavelle> memory usage?
07:31 <ertes-w> dysfun: because acid-state is not a "database"… it just keeps a persistent copy of *in-RAM* data
07:31 ragepandemic joined
07:31 <dysfun> ah, ok
07:32 <ertes-w> i would quickly scale down the number of containers i can run on a single host, if i used acid-state =)
07:32 <dysfun> heh
07:33 vektorweg1 joined
07:33 bennofs joined
07:33 coot joined
07:33 <ertes-w> also acid-state's checkpoints are full database rewrites… because sqlite has more structural information about the data, it can do checkpoints much more efficiently
07:34 <ertes-w> (you could probably teach acid-state how to do that, but not with the current safecopy-based approach)
07:35 jer1 joined
07:35 <* dysfun> has been trying to do something datomic-like in haskell, but doesn't know enough advanced ghc extensions
07:35 albertid joined
07:36 Proteus joined
07:36 oish joined
07:37 <phadej> dysfun: you don't need advanced ghc extensions for that
07:37 <dysfun> what?
07:37 <phadej> dysfun: to do "datomic" in Haskell
07:37 <dysfun> please, enlighten me :)
07:38 JeanCarloMachado joined
07:38 connrs joined
07:39 <bartavelle> dysfun, datomic is written in clojure, which isn't known for its advanced type extensions
07:39 <dysfun> yes, but unityping makes it much easier to implement
07:39 Levex joined
07:39 <phadej> dysfun: i'm not sure you are talking about the client or the server part
07:40 <dysfun> both
07:40 <phadej> but in both, you can get quite far without an extensions (and my gut feeling says to the end)
07:40 <dysfun> well, i can explain some of the things i've run up against and where my thoughts are and maybe you can suggest alternative approaches?
07:41 <phadej> except /if/ you want to encode schemas in type-level to make schema-violating queries impossible to construct
07:41 <dysfun> maybe later, but for now this isn't a concern
07:41 eklavya joined
07:42 takle joined
07:42 <phadej> and for the rest, there might be invariants you would like to enforce with types; but sometimes it's better ergonomics not to try to
07:42 <phadej> stick to GADTs and RankNTypes should get you quite far
07:42 <dysfun> the first difficulty is that a datom is effective a tuple of (E,A,V,T,Bool) and V is dependent on A. i couldn't figure out how to solve that without a type family
07:42 <phadej> GADT
07:44 <dysfun> a GADT would require me to define upfront all the typs that can be stored, wouldn't it?
07:44 <phadej> well, in datomic the types of V are closed universe
07:44 <phadej> which is only partially open as you can have references (but they are untyped)
07:44 <dysfun> the types are, but the attributes aren't
07:44 CurryWurst_ joined
07:45 indi_ joined
07:45 <phadej> dysfun: Use DataKinds and type-level string
07:45 <phadej> and make user of the library to provide the V (a :: A) GADT
07:45 <phadej> as the mapping is defined by the user
07:45 <phadej> (and you cannot really pass in type-families anyway)
07:45 <dysfun> okay, that could work, since i already have the user defining type instances
07:46 <dysfun> alright, i'll go play a bit more and i'll be back in a bit ;)
07:46 <dysfun> thanks
07:46 louispan joined
07:47 <phadej> dysfun: yet you probably need some V (e :: E) (a :: A) gadt actually, as different attribute may have different type depending on entity
07:47 <phadej> but not necessarily of course, if you decide so that same attribute has always the same type, whatever entity has it
07:47 chu joined
07:47 <phadej> design choices :)
07:48 JeanCarloMachado joined
07:48 <dysfun> yeah. datomic likes this namespaced keywords thing. to get that in haskell would mean using module namespaces which means a new module per entity. i think not
07:49 ExcelTronic joined
07:50 tasslehoff joined
07:50 <phadej> dysfun: you cannot pass modules in Haskell, so it won't work anyway
07:50 <phz_> hey, what is the de facto library for natural transformations?
07:50 <phadej> phz_: natural-transformations? :)
07:50 <phz_> I have a monad transformer like this:
07:50 <phz_> Foo a m
07:50 <dysfun> phadej: no, but you could use User.Name instead of UserName
07:50 <phz_> and I want to run Foo a n
07:50 <jle`> i don't think you need a library for natural transformations
07:50 <phadej> without `s`
07:50 <phz_> maybe I can go with MonadTransControl?
07:51 <phz_> I’ve never used that before
07:51 <phadej> phz_: that sounds like you want hoist from mmorph
07:51 <jle`> phz_: you might want mmorph
07:51 <phadej> ^ :+1:
07:51 <phz_> well, that’s a natural transformation, right?
07:51 <jle`> it is indeed a natural transformation
07:51 <tasslehoff> Trying to compile and run a haskell program on windows (I do not know haskell) I get:
07:51 <tasslehoff> C:/Program Files/Haskell Platform/7.10.3/mingw/x86_64-w64-mingw32/include/_mingw.h:542:34: syntax error before `:'
07:52 <jle`> phz_: hoist :: (forall x. m x -> n x) -> Foo w m a -> Foo w n a
07:52 <phz_> the type is not the same
07:52 <phz_> no it’s not
07:52 <phz_> hoist :: Monad m => (forall a. m a -> n a) -> t m b -> t n b
07:52 <phz_> well actually
07:52 <phz_> I guess it is :D
07:52 <jle`> i'm assuming `Foo a` is your monad transformer
07:52 mstruebing joined
07:52 watabou joined
07:52 <jle`> so it'd be 't' there
07:53 <jle`> it is indeed a natural transformation, but that doesn't mean that mmorph is a de facto library for natural transformations
07:53 <jle`> there are many natural transformations in base...
07:53 <jle`> listToMaybe, maybeToList
07:54 <jle`> that's like saying that because hmatrix uses Int, hmatrix is the de-facto library for Ints
07:54 allenleein joined
07:54 <phz_> jle`: well
07:54 <jle`> but it's not really; Int is everywhere
07:54 <phz_> I’m looking for the “natural transformation” library
07:54 <phz_> a bit like :~> from servant, you know
07:54 <jle`> what would such a library contain?
07:54 <phz_> typeclasses, mostly
07:55 <phz_> a bit like mtl / transformers
07:55 Xanather joined
07:55 <jle`> a natural transformation is just any forall a. f a -> g a
07:55 jer1 joined
07:55 <jle`> what kind of typeclasses are you talking about?
07:55 <phz_> that exactly
07:55 <jle`> just...one type?
07:55 ccomb joined
07:56 <jle`> the entire library is type Nat f g = forall a. f a -> g a? :)
07:56 fizruk joined
07:56 <phz_> well, I don’t know what the library would be
07:56 bweston92 joined
07:56 <phz_> but it’d be a generalization of natural transformations
07:56 <phz_> a bit like Arrows generalize functions
07:57 <phz_> anyway, the transformer is called ProdT actually
07:57 <jle`> so it wouldn't be about natural transformations...it'd be some typeclass, of which natural transformations are an instance of?
07:57 <phz_> ProdT a m b
07:57 <jle`> doesn't really sound like a natural transformation library
07:57 <phz_> it implements MonadBaseControl and MonadTransControl
07:57 <phz_> can I do what I want with those typeclasses?
07:57 <phz_> or do I need hoist?
07:57 <jle`> hoist is the most appropriate tool
07:58 <jle`> it lifts natural transformations to monad transformers
07:58 <phz_> I have ProdT a IO and ProdT a Handler (Handler from servant)
07:58 <phz_> I want to run the ProdT a IO in ProdT a Handler
07:58 <phz_> which should be “easy”
07:58 <phz_> since Handler implements MonadIO
07:58 <jle`> yes, sounds like just `hoist liftIO`
07:58 <phz_> I should be able to do that by passing through liftIO
07:58 andyhuzhill joined
07:58 <phz_> yeah
07:58 <phz_> so hoist seems to be the right tool
07:59 <phz_> thank you very much little bird :)
07:59 <jle`> mhm. hoist lifts natural tranformations on monads to natural transformations on monad transformers
07:59 <phz_> I’ll add mmorph as a dependency
07:59 <phz_> but is not possible with liftWith?
07:59 <phz_> (from MonadTransControl)
07:59 av joined
07:59 <jle`> it might be possible but hacky
07:59 <phz_> I always find it hard to read signatures from Monad{Base,Trans}Control
08:00 amosbird joined
08:00 <jle`> using :~>, hoist :: (m :~> n) -> (ProdT a m :~> ProdT a n)
08:00 <lpaste> av pasted “MMap space leak” at http://lpaste.net/355221
08:00 <av> Hi guys, I need some help with this: http://lpaste.net/355221
08:00 systadmin joined
08:00 javjarfer joined
08:00 <jle`> you might be able to use a MonadTransControl tools, but it'd definitely be the wrong too
08:01 <jle`> l
08:01 <av> This is meant to be a way of writing a very large data set (that doesn't fit in RAM) into a file on disk
08:01 oish joined
08:01 <jle`> hoist conveys the meaning that you want
08:01 <phz_> liftWith :: Monad m => (Run t -> m a) -> t m a
08:01 <phz_> type Run t = forall n b. Monad n => t n b -> n (StT t b)
08:01 <phz_> this is so hard to parse :D
08:02 <phz_> but yeah, I’ll add mmorph as dep.
08:02 <jle`> phz_: the "better" way to fix your problem would be to never have ProdT a IO in the first place
08:02 <jle`> but to always use `MonadIO m => ProdT a m`
08:02 <av> but is has a space leak -- I expected the amount of memory used to be mostly constant, but it increases with runtime, and quite significantly (400MB for the example code)
08:02 oisdk joined
08:02 tusj joined
08:02 <phz_> jle`: well
08:02 JeanCarloMachado joined
08:02 <jle`> that way it would already unify with ProdT a Handler
08:02 <phz_> I have a type working in ProdT a Handler
08:03 <av> can anyone tell me what I'm doing wrong?
08:03 <phz_> and I’m writing a function expecting something
08:03 <phz_> running in ProdT a ?
08:03 takle joined
08:03 <phz_> I can put (MonadIO m) => m if I want
08:03 <phz_> not sure how it’d react though
08:03 <jle`> this is actually the method that mmorph advices in its documentation
08:03 augur joined
08:03 <phz_> where?
08:04 Yuras joined
08:04 <jle`> http://hackage.haskell.org/package/mmorph-1.0.9/docs/Control-Monad-Morph.html
08:04 <jle`> see the section titled 'Tutorial'
08:04 <phz_> yeah, but I still need hoist, right?
08:05 <jle`> you would not need hoist if you had MonadIO m => ProdT a m
08:05 <jle`> because that already unifies with ProdT a Handler
08:05 <phz_> I’m trying
08:05 <jle`> you can just use it directly with ProdT a Handler
08:05 <phz_> • Couldn't match type ‘m’ with ‘Handler’
08:05 <jle`> no hoist necessary :)
08:05 <phz_> nope
08:06 <jle`> you might need to change some more type signatures
08:06 <phz_> yeah, it’s a bit tricky:
08:06 <phz_> ProdT args m Health -> ServerT HealthApi (ProdT args Handler)
08:06 <phz_> I never know what that ServerT resolves to in servant
08:06 <phz_> generally, it resolves to the monad
08:06 <phz_> so ProdT args Handler
08:06 <jle`> you can make it ProdT args Handler Health -> ...
08:07 <phz_> well I don’t want that
08:07 <phz_> because the parameter is passed from something that knows nothing about servant
08:07 <phz_> (and it should not)
08:07 <phz_> Expected type: ServerT HealthApi (ProdT args Handler)
08:07 <phz_> Actual type: ProdT args m NoContent
08:08 <phz_> I wonder how I can get away from that
08:08 <jle`> ah. yeah, then you have two options if the person calling doesn't have to know about servant
08:08 <phz_> that’s weird because they don’t even have the same kind
08:08 <jle`> you can have it take ProdT args IO Health and use hoist liftIO
08:08 <phz_> the former looks like it’s * -> *
08:08 <phz_> the latter is *
08:08 <phz_> yeah, that’s the first plan
08:09 <jle`> the second is to have it take a (forall m. MonadIO m => ProdT args m Health)
08:09 <jle`> which would already unify
08:09 <jle`> then the user would just be forced to provide something that is polymorphic for all MonadIO m
08:10 <jle`> the first is probably nicer overall/less burden to the user
08:10 <jle`> mmorph is arguably for the case where you don't control the types you receive
08:10 <phz_> hm
08:10 <jle`> s/don't control/have constraints on
08:10 <phz_> what is the syntax for forall again?
08:10 <phz_> I mean
08:10 <phz_> the language pragma
08:10 <phz_> not the syntax
08:11 kgadek joined
08:11 <jle`> it's RankNType
08:11 <phz_> ah yeah
08:11 <jle`> but not because of the forall necessarily
08:11 <phz_> ghc also tells me
08:11 <jle`> but because it would be a RankNType
08:11 <phz_> Rank2Type should make it
08:11 <jle`> yes, ghc is good at telling you what you need to do :)
08:11 <jle`> yeah, it would be a rank-2 type if you used it
08:11 <phz_> yeah!
08:11 <phz_> it works with Rank2Types
08:11 <phz_> neat
08:11 <phz_> thanks
08:11 <jle`> RankNTypes is usually preferred these days
08:11 <phz_> yeah, well
08:12 <phz_> I don’t need that much power
08:12 <phz_> I actually never saw anyone needing it
08:12 <jle`> but yeah, this imposes some burden to the user because they *have* to provide something polymorphic on all MonadIO m
08:12 <phz_> well
08:12 JeanCarloMachado joined
08:12 <phz_> they have to provide a signature like
08:12 <phz_> foo :: (MonadIO m) => ProdT args m b
08:12 <phz_> which is fine to me
08:12 <jle`> yeah
08:12 <phz_> hm
08:12 <phz_> actually
08:12 <phz_> it’s not
08:12 <jle`> that's exactly the burden
08:13 <phz_> damn.
08:13 <phz_> I guess I should go with IO.
08:13 <phz_> so, IO + hoist
08:13 <jle`> yeah, let the user provide ProdT args IO a
08:13 <jle`> and then hoist it internally when you receive it
08:14 kritzcreek joined
08:14 <phz_> so I need to write the MFunctor instance for ProdT
08:14 <phz_> it should be easy
08:15 <jle`> good luck!
08:15 <phz_> thank you for your precious help
08:15 <jle`> no problem
08:15 <phz_> this is for my job work :)
08:15 <jle`> actually in this case, ProdT doesn't already have a MFunctor instance?
08:15 <phz_> it’s so great doing that for a living :)
08:16 <phz_> no, it’s not
08:16 <phz_> but it’s just a ReaderT wrapped in a newtype
08:16 <phz_> so writing the instance will be easy peasy
08:16 jer1 joined
08:16 <jle`> so "use hoist" probably is not 100% technically correct advice
08:16 <jle`> since you still have to implement the lifting functionality
08:16 <phz_> yeah
08:16 takle joined
08:16 <phz_> but I guess my colleagues won’t find it damaging
08:16 <jle`> hoist would just be a nice everyone-understands-it polymorphic way of offering it
08:17 <phz_> I guess I could write the hoist “myself” without mmorph
08:17 <phz_> but offering it for future uses is ace
08:17 <phz_> I’ll write that in the MR.
08:17 <phz_> :P
08:17 <jle`> like if you defined a new numeric type, "how to add it? use +" would not be technically correct advice
08:17 <phz_> sure
08:17 <jle`> the real solution is to implement addition, and then you can write a Num instance and use (+) = add
08:17 <jle`> so people have a commonly accepted API
08:17 <jle`> but yeah, you get it :)
08:18 <jle`> actually, whatever ProdT is a newtype wrapper over might already have an MFunctor instance
08:18 <phz_> MFunctor (ReaderT * r)
08:18 <jle`> definitely lucky to be able to do haskell for work though :)
08:18 <phz_> yep :D
08:18 <phz_> so I guess I can derive it automatically
08:18 <phz_> let’s see.
08:18 <phz_> yeah I’m lucky
08:18 <phz_> and I have cool colleagues :)
08:19 <phz_> haskellers as well
08:19 <jle`> :D
08:19 fizruk joined
08:19 <phz_> YES
08:19 <phz_> automatically derived
08:19 <phz_> that’s so ace
08:19 tromp joined
08:19 <phz_> jesus I love it.
08:19 <jle`> haskell is the best
08:22 Levex joined
08:22 halogenandtoast joined
08:23 tomphp joined
08:25 JeanCarloMachado joined
08:26 _sras_ joined
08:26 soniku joined
08:27 refold joined
08:28 <_sras_> I have Servant web app that have handlers that run in a custom Monad. I also have a `body check` that runs in `IO`. Is there anyway to run the body check to run in the same Monad as that of the handlers......?
08:28 eacameron joined
08:28 thc202 joined
08:29 <opqdonut> _sras_: is IO part of your custom monad stack? then use liftIO
08:29 <opqdonut> :t liftIO
08:29 <lambdabot> MonadIO m => IO a -> m a
08:29 hurkan joined
08:30 lep-delete joined
08:30 <_sras_> opqdonut: That is not the issue. My custom monad requires a reader Environment that contans a couple of stuff. I can run the App monad in the body check if I am willing to duplicate all the work setting up the evn for the reader. I am looking for a way around that.
08:32 <_sras_> The app Monad is also not an instance of MonadIO...
08:32 DrMentats left
08:33 rogl joined
08:35 sanitypassing joined
08:35 rogl joined
08:36 dm3 joined
08:37 jer1 joined
08:37 <ReinH> Is the base of the app monad IO?
08:38 blym_ joined
08:39 marr joined
08:40 JeanCarloMachado joined
08:40 mrijkeboer joined
08:41 Yuras joined
08:41 Wingsorc joined
08:43 benl23 joined
08:43 mohsen_ joined
08:43 kuribas joined
08:44 alqatari joined
08:44 cgfbee joined
08:45 jeltsch joined
08:45 Icewing joined
08:46 <_sras_> ReinH: Yes
08:46 <ReinH> Then why not make it an instance of MonadIO?
08:47 <kuribas> Why does ghc complain about TypeApplications? http://paste.lisp.org/display/345840
08:47 <kuribas> I already have it as a language pragma
08:47 <ReinH> since that's the only way you're going to run an IO action in it without unwrapping it and rewrapping it manually, which is what you seem to be trying to avoid
08:48 <ReinH> (or something equivalent but more complex like monad-base-control)
08:48 <rightfold> How do I import (+) from GHC.TypeLits?
08:48 <ReinH> kuribas: you should include the error message
08:49 <kuribas> ReinH: "Pattern syntax in expression context: read@Double Did you mean to enable TypeApplications?"
08:50 <alexbiehl> kuribas: try a space between read and @Double
08:50 <alexbiehl> *inserting
08:50 <jle`> rightfold: import GHC.TypeLits ((+)) ? if that doesn't work, import GHC.TypeLits (type (+))
08:50 <rightfold> Do I need an extension for that?
08:50 <jle`> one way to find out
08:51 <kuribas> alexbiehl: thanks, that seems to be it!
08:51 <rightfold> (+) gives an error because it can't find the value (+), type (+) gives a syntax error with no mention of an extension
08:51 yoneda joined
08:52 <jle`> rightfold: ah yeah, you need TypeFamilies it seems
08:52 <av> anyone who could help me with this? http://lpaste.net/355221
08:53 acidjnk22 joined
08:53 <jle`> av: it looks like it's cause you're using 'length d'
08:54 <_sras_> ReinH: isn't liftIO used to run IO in an instance of MonadIO? I want to run a function that is in different Monad in IO...
08:54 <jle`> which forces the entire list spline into memory
08:54 watabou joined
08:54 <jle`> that's my suspicion
08:54 <jle`> av: i would just pattern match on the result of splitAt
08:54 <_sras_> ReinH: The body check should run in IO. But by validation function should run the the custom app monad...
08:54 <ReinH> _sras_: what different monad?
08:55 <rightfold> jle`: thanks I'll try it
08:55 <_sras_> ReinH: You can assume that it is just a Reader.
08:55 <jle`> av: if you splitAt 65536, then the second item will be [] if the list is too short
08:55 <jle`> > splitAt 1000 [1..10]
08:55 <lambdabot> ([1,2,3,4,5,6,7,8,9,10],[])
08:55 <rightfold> Seems weird though, I think I need TypeOperators
08:55 <ReinH> what's the type of this 'body check'?
08:55 <jle`> rightfold: you shouldn't need TypeOperators unless you actually use (+) as a type operator
08:55 fotonzade joined
08:56 zero_byte joined
08:56 <jle`> if you use it in prefix form then there should be no trouble
08:57 <jle`> not that TypeOperators is an extensio you should avoid
08:57 jer1 joined
08:57 <jle`> my point was just that you don't need to have it to import t :)
08:58 andyhuzhill1 joined
08:58 <_sras_> ReinH: bodyCheck :: () -> DelayedIO a
08:58 <rightfold> > In types, an operator symbol like (+) is normally treated as a type variable, just like a.
08:58 <lambdabot> <hint>:1:9: error: parse error on input ‘,’
08:58 <ReinH> Well, then you'll need some way of converting that to an IO action.
08:59 <ReinH> I'm not sure what DelayedIO is, or why it's a function from ().
08:59 <rightfold> jle`: seems I need ExplicitNamespaces
08:59 <_sras_> ReinH: Yes. that is my question....
08:59 <jle`> you shouldn't need explicit namespaces
08:59 <ReinH> Well, we can't tell you how to do that without knowing what DelayedIO is.
08:59 <_sras_> ReinH: I know how to convert it to IO. But I am looking for a way not to duplicate it...
09:00 oish joined
09:00 <ReinH> duplicate what?
09:00 <kuribas> > printf "%.1f" 4.0 -- how do I get "4.0"?
09:00 <jle`> oh, hm, yes, it's ExplicitNamespaces, i just never used it because TypeFamilies includes it
09:00 <lambdabot> error:
09:00 <_sras_> ReinH: Say. My AppMonad is a Reader, you need an Environment to run this reader and get a value in IO, right?
09:00 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M304655720505...
09:00 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
09:01 <kuribas> > printf "%.1f" (4.0::Double) -- how do I get "4.0"?
09:01 <lambdabot> error:
09:01 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M705704316461...
09:01 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
09:01 <jle`> > printf "%.1f" (4.0 :: Double) :: String
09:01 <lambdabot> "4.0"
09:01 <jle`> kuribas: what are you getting?
09:01 <jle`> if not 4.0 ?
09:01 <kuribas> "4"
09:01 <jle`> huh
09:01 <ReinH> _sras_: I assume you mean ReaderT Env IO a or similar?
09:01 <_sras_> ReinH: Yes.
09:02 <ReinH> @unmtl ReaderT Env IO a
09:02 <lambdabot> Env -> IO a
09:02 <jle`> rightfold: i tested it on my end and you should only need TypeFamilies
09:02 ckubrak joined
09:02 <ReinH> if you're running a ReaderT Env IO a, action, you have already supplied an Env
09:02 <jle`> or well, TypeFamilies should be sufficient, at least
09:03 <ReinH> if you're *constructing* one, you haven't.
09:03 <av> jle`: thanks so much, I think you pushed me in the right direction
09:03 <ReinH> so I'm not sure what you think would be duplicated
09:03 <jle`> av: no problem!
09:03 <jle`> av: yes, usage of length for lists is often a red flag
09:03 <kuribas> > (printf "%.1f" (4.0::Double)) :: IO ()
09:03 <lambdabot> <IO ()>
09:03 jaspervdj joined
09:03 <jle`> av: especially if you use streamy things on it like take/drop/splitAt
09:04 andyhuzhill joined
09:04 <ReinH> it's best not to think of lists as a structure with a length, but rather as an inductive structure defined by nil and cons
09:04 <_sras_> ReinH: I have a validation function that runs the body check. If that is in IO, then there is no issue. But I want it to be in the Reader monad.
09:04 <jle`> kuribas: not sure why you are getting 4, it is 4.0 on everything i'm testing it on :/
09:04 <ReinH> Again, if you mean ReaderT Env IO a, that's what liftIO is for.
09:04 <kuribas> jle`: I am inside the editor on hackerrank
09:04 <jle`> av: note also for 'if n == 0'
09:05 <jle`> av: you probably really wanted case d2 of [] -> ...
09:05 Gurkenglas_ joined
09:05 <_sras_> ReinH: What is liftIO for?
09:05 <jle`> er, well, case d of [] -> ...
09:05 <ReinH> :t liftIO
09:05 <lambdabot> MonadIO m => IO a -> m a
09:05 <jle`> liftIO :: IO a -> ReaderT Env IO a
09:05 <kuribas> jle`: erm never mind, I am reading the wrong output :-P
09:05 <ReinH> converting an IO action to an action in a monad that is an instance of MonadIO
09:06 <_sras_> I want to run a Reader in IO. Not the other way around.
09:06 <kuribas> jle`: I actually "need" 4 as output
09:06 <ReinH> That's not what you've been saying though
09:06 <jle`> heh
09:06 <kuribas> jle`: sorry about that...
09:07 <ReinH> :t runReaderT
09:07 <lambdabot> forall k (a :: k) (m :: k -> *) r. ReaderT r m a -> r -> m a
09:07 <kuribas> So now I need to know how to remove the 0
09:07 <ReinH> runReaderT converts your ReaderT Env IO a into Env -> IO a
09:07 <jle`> > printf "%.0f" (4.0 :: Double) :: String
09:07 <lambdabot> "4"
09:08 takle joined
09:08 <_sras_> ReinH: Yes. So I have to run this runReaderT here, in this 'body check' function, right?
09:08 <ReinH> No
09:08 <_sras_> ?
09:08 <kuribas> > printf "%.0f" (4.425 :: Double) :: String
09:08 <lambdabot> "4"
09:08 <ReinH> you do the opposite, use liftIO to convert body check to run in ReaderT Env IO a
09:09 <ReinH> since the ReaderT monad is the Servant monad, that's the context you need to run it in
09:09 <jle`> kuribas: is that not what you want?
09:09 <_sras_> ReinH: This happens *before* the execution hit the handlers. Tht is the whole issue.
09:09 <kuribas> jle`: unfortunately I need 4.4 in this case
09:10 <jle`> so you want 4.0 => "4", 4.425 => "4.4" ?
09:10 <ReinH> What do you mean, before the execution hit the handlers?
09:11 <jle`> round to one decimal place, and drop the .0 if it's .0 ?
09:11 <kuribas> jle`: yeah, that's what hackerrank expects.
09:11 <kuribas> jle`: yeah, I suppose I need something custom
09:12 nh2 joined
09:12 <jle`> > reverse . stripPrefix "0." . reverse $ "4.0"
09:12 <_sras_> ReinH: Body check does not happen inside the handlers....
09:12 <lambdabot> error:
09:12 <lambdabot> • Couldn't match type ‘Maybe [Char]’ with ‘[a]’
09:12 <lambdabot> Expected type: [Char] -> [a]
09:12 <jle`> aw
09:12 <ReinH> Then what does the ReaderT have to do with it?
09:13 rory joined
09:13 <ClaudiusMaximus> > {- print . -} reverse . dropWhile (=='.') . dropWhile (=='0') . reverse . printf "%.1f" $ 4.0
09:13 <lambdabot> "4"
09:13 <ClaudiusMaximus> oh probably putStrLn, as it's a String by then
09:13 <_sras_> ReinH: I want the validation function to use the Env in reader T. So I am looking for a way to carry the environment created at this point (Body check), all the way into the handlers...
09:14 NinjaTrappeur joined
09:14 <ReinH> it's an env, so it's read-only anyway. Just pass it around until you wrap it up in the ReaderT via runReaderT?
09:14 <jle`> @let stripPrefix' p x = fromMaybe x (stripPrefix p x)
09:14 <lambdabot> Defined.
09:14 <ReinH> er, it's a reader so it's read-only
09:14 <jle`> > reverse . stripPrefix' "0." . reverse $ "4.0"
09:14 <lambdabot> "4"
09:14 <jle`> > reverse . stripPrefix' "0." . reverse $ "4.1"
09:14 <lambdabot> "4.1"
09:14 <kuribas> > putStrLn $ takeWhile (/= ".") $ printf "%.1f" (4.24::Double)
09:14 <lambdabot> error:
09:14 <lambdabot> • Couldn't match type ‘[Char]’ with ‘Char’
09:14 <lambdabot> Expected type: String
09:14 <_sras_> ReinH: Body check is part of the Servant's infra. I am looking for a way to
09:15 splanch joined
09:15 <_sras_> pass it around...
09:15 <kuribas> > putStrLn $ takeWhile (/= '.') $ printf "%.1f" (4.24::Double)
09:15 <lambdabot> <IO ()>
09:15 <ReinH> fmap reverse . (stripPrefix =<<) . fmap reverse . pure ?
09:15 <kuribas> > takeWhile (/= '.') $ printf "%.1f" (4.24::Double)
09:15 <lambdabot> "4"
09:15 <Xnuk> > show . floor $ read "4.1"
09:15 <lambdabot> "4"
09:16 <kuribas> nvm
09:16 <_sras_> ReinH: The body check happens inside an Type class instance definition, which apprently get used by Servant at some point. I don't know how to pass stuff out of it...Which is what i am looking for.
09:16 splanch_ joined
09:17 zariuq joined
09:17 <ReinH> I'm not sure what you're asking at this point. It doesn't seem to bear much resemblance to your original question.
09:18 jer1 joined
09:18 <ReinH> You said you have a body check that runs in IO, but it does not run in IO.
09:18 <ReinH> You said you need to run it in a ReaderT, but you do not need to run it in a ReaderT
09:19 <jle`> > reverse . (fromMaybe <*> stripPrefix "0.") . reverse $ "4.1"
09:19 <lambdabot> "4.1"
09:19 <jle`> > reverse . (fromMaybe <*> stripPrefix "0.") . reverse $ "4.0"
09:19 balor joined
09:19 <lambdabot> "4"
09:19 <ReinH> At this point, I think you should work on coming up with a better problem description.
09:20 tromp joined
09:21 <_sras_> ReinH: Sure. I think It should be clear for someone familiar with Servant...
09:22 <ReinH> Well, I think it would be clear once you state your problem clearly. I've used Servant.
09:23 <_sras_> ReinH: I think most people who use Servant does not have to bother with things like this...
09:24 <ReinH> The body check is part of the routing internals
09:24 <_sras_> Yea..
09:24 <ReinH> I'm not sure why you would need to access it in an application
09:24 balor joined
09:25 <ReinH> generally, internal modules are not meant to be consumed by library users
09:25 bjz joined
09:25 <_sras_> ReinH: I am adding Validations to json payloads before it hits the handlers...
09:26 qqwy joined
09:27 <kuribas> > let writeDouble d = show ip ++ if fp == 0 then "" else "." ++ show (truncate (fp*10)) where (ip, fp) = properFraction d in writeDouble 4.24 -- jle` this works too
09:27 <lambdabot> "4.2"
09:27 <ReinH> I believe that sort of thing is usually done by writing a custom HasServer instance
09:27 <qqwy> Good day everyone!
09:27 rory left
09:27 soniku joined
09:27 <ReinH> Ah yeah, this sort of thing https://github.com/haskell-servant/servant/issues/24
09:27 oisdk joined
09:27 <_sras_> ReinH: That is exactly what I am doing
09:27 bjz joined
09:28 <_sras_> ReinH: This body check happens inside that instance definition..
09:28 <ReinH> But you don't need to use a body check, you can just add your validation to route resolution
09:28 <ReinH> by implementing route appropriately
09:29 <ReinH> you can run arbitrary IO in that context
09:29 <ReinH> and then have return a failing response if the validation fails
09:29 <ReinH> s/have //
09:30 xtreak joined
09:31 <qqwy> I am in the process of reading the 'what I wish I knew when learning Haskell' guide. (What a wonderful guide!)
09:31 <qqwy> I was wondering: When/where are bifunctors used/useful in practice?
09:31 niez joined
09:31 <ReinH> The suggestion for dealing with some config at that point seems to be an IORef o_O
09:32 <_sras_> ReinH: Yes. I can run arbitrary IO. But I need to create the env for the Reader monad (my App monad, which I want the validation to run in)...
09:32 <ReinH> but I don't really see much alternative, given the way it's designed
09:32 <_sras_> ReinH: Ok. I thought about that option...
09:34 <ReinH> Yeah, I don't know if servant has a better way to handle this now, but this isn't awesome.
09:35 blym_ joined
09:35 <ReinH> validation should really run in the handler so it has access to your app context
09:35 quobo joined
09:37 <ReinH> Combinators at one point were explicitly designed to only offer the request context
09:38 <ReinH> I think you might be looking for Context
09:38 jer1 joined
09:38 <ReinH> https://hackage.haskell.org/package/servant-0.1/docs/Servant-Context.html
09:38 <ReinH> wait no that's old
09:40 cschneid_ joined
09:40 <ReinH> http://hackage.haskell.org/package/servant-server-0.10/docs/Servant-Server.html#g:9
09:40 <ReinH> Yeah, that
09:40 deank joined
09:40 <tsahyt> how would I go about short-circuiting a fold?
09:40 <ReinH> tsahyt: depends on the fold
09:40 <ReinH> foldr is guarded, foldl is not
09:41 <ReinH> > foldr (||) False (repeat True)
09:41 <lambdabot> True
09:41 <tsahyt> I've got say a [Either Foo Bar]. I want to return on the first Right encountered, but in case there is no Right I need to do a monoid operation over all the Foos encountered
09:41 <ReinH> so anything non-strict will short-circuit
09:41 <ReinH> if the argument isn't scrutinized
09:41 <ertes-w> tsahyt: http://ertes.eu/tutorial/foldr.html#example-take
09:42 <ReinH> You can do that with a folding function that is appropriately non-strict
09:42 <_sras_> ReinH: Yes. Will take a look
09:43 <tsahyt> ertes-w: thanks, I'll read that
09:44 eklavya joined
09:44 <ReinH> foldr (either mappend const) (Left mempty)
09:44 gehmehgeh joined
09:44 rockfordal joined
09:44 <ReinH> might be what you want
09:44 alif_bae joined
09:44 <tsahyt> looks about right, yes
09:44 <ertes-w> tsahyt: here is another one: http://ertes.eu/tutorial/foldr.html#example-null
09:44 <tsahyt> ertes-w: I think I should set some time aside to read the whole thing actually
09:45 <ertes-w> tsahyt: yet another one: http://ertes.eu/tutorial/foldr.html#heads-tails-and-a-digression
09:45 <ertes-w> tsahyt: yeah, i think it's the most comprehensive foldr tutorial available right now =)
09:45 <tsahyt> ertes-w: bookmarked
09:45 polll joined
09:45 <ertes-w> and you can easily transfer the knowledge to other algebraic data structures
09:45 <ertes-w> like folding trees
09:46 <tsahyt> ertes-w: does any Foldable support short-circuiting behavior for foldr?
09:46 <tsahyt> or rather does *every* Foldable support it
09:46 <ertes-w> tsahyt: no
09:46 locallycompact joined
09:46 <tsahyt> hmpf. I guess I can enforce it by doing toList though
09:46 <ertes-w> tsahyt: a snoc-list will support it with foldl
09:46 <ReinH> er, bimap
09:47 <ertes-w> tsahyt: using toList will not help =)
09:47 <ReinH> ertes-w: I guess that depends on whether you think foldr is for right-associative folding or guarded folding
09:47 <tsahyt> ertes-w: why not?
09:47 <ReinH> which happen to coincide for lists
09:47 <ReinH> but not for snoc lists
09:48 <ertes-w> tsahyt: if you want to be safe, the only option is to use fold/foldMap with a suitable short-circuiting monoid
09:48 <ertes-w> that short-circuits on both sides
09:48 <tsahyt> hmm that'd have to be a custom monoid I guess
09:49 <ertes-w> tsahyt: but if your data structure is list-like or tree-like, then honestly i would just assume that foldr does the usual left-to-right thing
09:49 <ertes-w> the counterexamples are mostly theoretically interesting edge cases
09:50 <ertes-w> like snoc lists… nobody uses snoc lists =)
09:50 <tsahyt> ertes-w: the public facing API requests a function (a -> t b) where t is Foldable and a Functor. I was expecting to just keep working on what I'm being supplied. though in reality anything that isn't somewhat list-like probably doesn't make too much sense
09:50 <tsahyt> it'd either be Sets or HashSets or [] etc
09:50 <ReinH> I use snoc lists :p
09:50 <tsahyt> it's basically the successor function for a graph search algorithm
09:51 <ReinH> snoc vects make vect zippers correct by construction
09:51 <Gurkenglas_> tsahyt, Control.Monad.Trans.Either has the Alternative instance such that asum has the behavior you specified
09:51 <ertes-w> well, yeah… you can always go safe and use foldMap
09:52 <ReinH> ertes-w: personally, I think foldr is unfortunate because guardedness is often more important that associativity
09:52 tomphp joined
09:53 <ertes-w> ReinH: yeah
09:53 <ReinH> I'd rather have foldr on snoc lists be a guarded left fold, but then it's named wrong.
09:53 <tsahyt> ertes-w: that reduces the problem to finding a suitable monoid
09:53 <ertes-w> personally i think there should be a variant of foldMap that abstracts over (<>) and mempty instead of Monoid
09:53 <ertes-w> and that one should be primitive
09:53 <ReinH> I think we should characterize folds by guardedness or tail recursiveness tbh
09:53 <ReinH> "tail recursiveness"
09:54 <tsahyt> I wonder whether I can somehow get away without writing a custom monoid for it
09:54 <tsahyt> i.e. cobbling it together from existing pieces
09:54 watabou joined
09:55 <ertes-w> tsahyt: if you're going to end up with a product monoid, you can use the 'generic-deriving' package
09:55 <ReinH> i.e., there's a guarded tree fold that is neither a foldl nor a foldr by left-to-right travesal order
09:55 <ReinH> for binary trees
09:55 <ertes-w> tsahyt: it will write product monoids for you automatically
09:55 <ertes-w> (or you can just use tuples, of course)
09:55 <ertes-w> ReinH: i agree
09:55 <tsahyt> ertes-w: since it's just a temporary structure I wouldn't mind using tuples
09:56 <tsahyt> time to investigate the monoid zoo then
09:56 <ReinH> ertes-w: at least, I don't want to have to guess at guardedness because my only choices are right or left
09:56 <ReinH> (or foldMap, ok)
09:56 <ertes-w> tsahyt: this one is predefined: instance (Monoid a, Monoid b) => Monoid (a, b)
09:56 <ertes-w> tsahyt: only if you need custom semantics you need to write your own instance
09:57 <ReinH> Hmm, is there something in These?
09:57 sgronblo joined
09:57 takle joined
09:57 <ertes-w> ReinH: foldMap is unfortunate, too, because it loses all information about the "sequenceness" of the structure
09:58 <ertes-w> implementing 'take' in terms of foldMap makes you question your own function, and with good reason
09:58 <ertes-w> while 'take' for lists is perfectly reasonable, for Foldable it's questionable
09:58 <ReinH> heh
09:59 <ReinH> ertes-w: yeah, if only we could program generically over eliminators
09:59 jer1 joined
09:59 NyanPasu joined
09:59 <ReinH> I guess I just want Epigram
09:59 <tsahyt> why does Either in base not have an Alternative instance to begin with?
09:59 <rightfold> Why do I need standalone deriving for Eq when using existentials?
09:59 <ertes-w> in particular, if the structure is tree-like, i would expect something like a Foldable-based 'take' to do depth cutoff, not "get number of elements"
09:59 <Gurkenglas_> :t partsOf -- why isn't it "(Functor f, Traversable g) => Traversing (->) f s t a a -> LensLike f s t (g a) (g a)"?
10:00 <lambdabot> Functor f => Traversing (->) f s t a a -> LensLike f s t [a] [a]
10:00 <tsahyt> i.e. Monoid e => Alternative (Either e)
10:00 <rightfold> tsahyt: what would empty be?
10:00 <tsahyt> rightfold: mempty
10:00 <tsahyt> Left mempty
10:00 <ReinH> ertes-w: Hmmm, you can get this for those foldables which are cofree comonads, I believe
10:00 <ReinH> you can write levels, which is take for lists and levels for trees
10:00 <ertes-w> ReinH: you can't, because you can't reconstruct
10:00 <ReinH> ok, you can get something else which is better anyway :p
10:00 <rightfold> tsahyt: that's rather arbitrary
10:01 <tsahyt> rightfold: that's also taken from the either package
10:01 <ertes-w> ReinH: to be honest, Foldable is a really odd class… but it the same time it's quite useful, if you just pretend that it's a fancy version of toList =)
10:01 <Gurkenglas_> I don't think it's arbitrary, Monoid has exactly the tools you'd need for Alternative (Either m)
10:01 <ertes-w> the proper way to do this is with bananas, lenses, something else and barbed wire =)
10:01 <tsahyt> rightfold: but there it is defined for EitherT
10:01 <ReinH> ertes-w: Foldable is mostly there for Traversable.
10:02 wonko7 joined
10:02 <Gurkenglas_> Consider the monoid instance required for Writer
10:02 <ReinH> For example, the best answer to "Why is (a,) Foldable?" is "So that it can be Traversable."
10:02 jhrcek joined
10:02 <ertes-w> "why is (a,) Traversable?"
10:02 <ertes-w> =)
10:02 <ReinH> As a Foldable, it is silly. It's a useful Traversable, though.
10:03 <ertes-w> "so that you can use it as a lens"
10:03 <ReinH> Because (a,) is things with a label
10:03 <ReinH> haha
10:03 <ReinH> touché
10:03 <tsahyt> ReinH: silly or not, everything that is required from a Foldable can be done on (a,), so the instance should exist imo
10:03 <ReinH> tsahyt: That's a silly reason for things to exist
10:04 romank joined
10:04 <tsahyt> ReinH: I'd rather have that than having to deal with orphan instances and whatever alternatives to that I can cook up for when I might have need for such an instance
10:04 <ertes-w> more importantly there are only two implementations of (Foldable (a,)), and only one of them is useful
10:04 <ertes-w> ah, no… you can actually have infinitely many implementations
10:04 <ertes-w> but only one is useful =)
10:04 <ReinH> I mean, length is another poorly named holdover from centering lists
10:04 tomphp joined
10:04 <ertes-w> so yeah, i agree: it should exist
10:05 DocWinter joined
10:05 <ertes-w> ReinH: i think 'length' is fine
10:05 <ReinH> it makes perfect sense that (a,b) contains one b
10:05 <ReinH> but people get hung up on kength
10:05 <ReinH> because (a,b) contains two things
10:05 <tsahyt> ReinH: I always thought the only reason to put length into the class was that it allows for efficient implementation in many cases
10:05 <tsahyt> e.g. for vectors or Set. things that store their size
10:05 <ertes-w> it contains one point
10:05 <ertes-w> (and one label)
10:05 balor joined
10:05 jship joined
10:05 <ReinH> Yeah, but the name length is confusing
10:06 <ReinH> because it's not the length of the structure
10:06 <ReinH> it's the count of the points in the structure
10:06 <ReinH> it's closer to cardinality than length
10:06 <ReinH> maybe size would be better
10:06 richi235 joined
10:06 <tsahyt> I guess points would be somewhat accurate
10:06 Wizek joined
10:06 <rightfold> foldsucc
10:08 Kreest__ joined
10:10 <Gurkenglas> takeCPS :: Foldable f => Int -> f a -> (forall g. Foldable g => g a -> b) -> b
10:11 balor joined
10:11 jer1 joined
10:12 alif_bae joined
10:12 eacameron joined
10:13 gmcabrita joined
10:18 ziocroc2 joined
10:21 <kuribas> Does :: have higher precendence than $?
10:22 <Gurkenglas> The precedence of $ is low, and that of :: is lower
10:22 obihann joined
10:23 <kuribas> right, thanks
10:23 jeltsch left
10:23 <kuribas> I expected :: to have the same precedence as application, but I was wrong.
10:24 jeltsch joined
10:24 <jeltsch> I am experiencing a weird problem with “untouchable” type variables.
10:24 alif joined
10:24 <jeltsch> The code that exposes this problem and the error message are at http://lpaste.net/355224.
10:26 <jeltsch> I have no clue what “untouchable” type variables are and why GHC is introducing the type variable c0 mentioned in the error message, given that the type variable c is defined at the outermost level and has nothing to do with the type family F.
10:26 splanch joined
10:28 govg joined
10:30 <* geekosaur> suspects this requires an impredicative type somewhere
10:30 mda1 joined
10:31 m1911 joined
10:32 tomphp joined
10:32 obihann joined
10:33 Wizek_ joined
10:33 xtreak joined
10:34 <niez> Gurkenglas, precedence of :: ? kuribas is talking about 'has type'? in this context talking about precedence doesn't makes sense to me, what am I missing?
10:34 n3glv joined
10:35 <ertes-w> ReinH: you don't assume that "size" will be any less confusing than "length", do you? ;)
10:35 <ertes-w> ReinH: it's the "what's a good name for 'return'?" thing all over again =)
10:35 <ReinH> it is
10:35 <Gurkenglas> niez, does "a $ b :: c" behave like "a $ (b :: c)" or "(a $ b) :: c"?
10:36 <ertes-w> i think 'length' is fine, after you have explained Foldable
10:36 <ertes-w> it also fits with its iterative nature
10:36 <kuribas> niez, Gurkenglas yes, I suppose you cannot mix (::) with operators
10:36 <kuribas> > 1 :: Int + 2
10:36 <lambdabot> error:
10:36 <lambdabot> Not in scope: type constructor or class ‘+’
10:37 <kuribas> > (1 :: Int / 2)
10:37 <lambdabot> error:
10:37 <lambdabot> Not in scope: type constructor or class ‘/’
10:37 <Gurkenglas> kuribas, obviously we restrict ourselves to compiling expressions
10:37 <ReinH> > 1 + 2 :: Int
10:37 <lambdabot> 3
10:37 darlan joined
10:37 <niez> ah, ok, so it's about 'has type', not an ordinary function (::)
10:38 <jeltsch> geekosaur: Can you elaborate on this? What has this to do with impredicativity?
10:38 Atlantic777 joined
10:38 Atlantic777 joined
10:38 <Gurkenglas> There are other operators where you can talk about precedence but switching them around stops compilation
10:40 <hexagoxel> let type (+) = Either
10:40 <hexagoxel> > Left 1 :: Int + Bool
10:40 <lambdabot> Left 1
10:41 blym_ joined
10:41 <hexagoxel> isn't that "mixing with operators"?
10:41 <hexagoxel> only thing is the "precedence" of "::" (it is syntax, but the concept still makes sense)
10:42 sgronblo joined
10:42 <kuribas> hexagoxel: here + is a type constructor?
10:42 <niez> :: isn't part of the expression, is is a type _annotation_, just a hint to the compiler, it isn't used to compute a value, I belive kuribas meant this
10:43 jgertm joined
10:43 netheranthem joined
10:43 ogrady_ joined
10:43 <hexagoxel> kuribas: yes
10:43 <kuribas> > (1 :: Int) + (2 ::Int) -- this is an expression
10:43 <lambdabot> 3
10:43 eklavya joined
10:43 <hexagoxel> but aren't we talking syntax? why does the value/type distinction matter?
10:43 <kuribas> niez: I think it's still part of the expression
10:44 ogrady_ joined
10:44 coeus joined
10:45 a3Dman joined
10:45 <kuribas> hexagoxel: I think (::) parses as (expr :: type), so maybe no precedence is used in the parser...
10:45 <jeltsch> kuribas, niez: If e is an expression and t is a type, then e :: t is also an expression. The point is that :: is not an operator. So the construct e :: t is not application of an infix operator; it is a different kind of expression.
10:46 <tsahyt> any reason other than historical that mconcat /= fold?
10:46 <niez> ok, anyway, :info (::) gives an error, so from my point of view it has no precedence at all
10:46 <niez> am I wrong?
10:46 <jeltsch> The :: binds less than anything else, I think. At least less than any operator and λ-expressions.
10:46 <ReinH> It isn't an operator
10:46 <hexagoxel> a valid stance. then "function application" has no precedence either.
10:46 <balor> I have an Aeson object. I'd like to descend the object looking for the value of certain keys. Is there a way to map over the object with an accumulator?
10:46 bigos_ joined
10:46 <ReinH> operators have precedence
10:46 <ReinH> its parse is defined by the grammar
10:47 <ReinH> as is function application
10:47 <jeltsch> Operators and :: have precedence, so to say. This does not mean that you can use :: with :info.
10:47 <cocreature> balor: just write a recursive function?
10:47 <jeltsch> :info is only for identifiers and operators, AFAIK.
10:47 <jeltsch> You also cannot say :info data or :info let.
10:47 <balor> cocreature, Thanks. I just thought there may be a more elegant approach.
10:48 <cocreature> balor: what exactly do you mean by “map over the object”?
10:48 dedgrant_ joined
10:48 Durbley_ joined
10:49 torstein_ joined
10:49 Gloomy joined
10:49 mfukar_ joined
10:49 <balor> cocreature, by that I mean descent each of the objects and arrays from the parent, looking for objects with key=value.
10:49 descender joined
10:49 a_a_shlykov joined
10:50 a_a_shlykov left
10:50 juhp joined
10:50 <cocreature> balor: you might be able to use transformM from uniplate and keep the accumulator in a State monad
10:51 <balor> cocreature, thanks.
10:51 <cocreature> but whether that’s worth the effort is questionable
10:52 a_a_shlykov joined
10:53 xificurC joined
10:54 safe joined
10:55 watabou joined
10:56 ogrady joined
10:57 pungi-man joined
10:58 Wuzzy joined
10:59 <xificurC> is there some sort of summary (or can someone summarize here) the state of haste, ghcjs and purescript regarding - completeness, maintenance, userbase, packages, using js packages, FFI, resulting size? These are some of the important things that come out of the top of my head but it takes a while to look for answers on each of them for each impleme
10:59 <xificurC> ntation. I'm lazy :)
11:01 geekosaur joined
11:01 mada joined
11:01 Gloomy joined
11:02 Snircle joined
11:04 cyborg-one joined
11:06 a3Dman joined
11:06 a3Dman joined
11:07 geekosaur joined
11:08 a_a_shlykov joined
11:09 tomphp joined
11:10 rcat joined
11:11 <tsahyt> is there a way to set a memory limit in ghci?
11:11 <tsahyt> like with +RTS -M1G when calling an executable
11:13 a_a_shlykov left
11:13 abhiroop joined
11:14 expo873_ joined
11:14 nick8325 joined
11:17 ckubrak joined
11:18 acarrico joined
11:19 ThomasLocke joined
11:19 ragepandemic joined
11:20 soniku joined
11:21 <Gurkenglas> balor, can it happen that a key with the specified value maps to another object that might contain the key again?
11:21 <balor> Gurkenglas, yes.
11:22 asmyers joined
11:22 smillmorel joined
11:23 mohsen_ joined
11:24 oisdk joined
11:24 Gloomy joined
11:24 <Gurkenglas> balor, the accumulator is a Monoid and it's fine if recursively deeper occurences appear first in the mappending?
11:25 <balor> Gurkenglas, Yes. Order is not important.
11:25 <hexagoxel> tsahyt: afaik calling ghci with +RTS -M1G is the only option; the rts does not provide the api to change things at runtime (to ghci or others).
11:26 ogrady joined
11:26 tomphp joined
11:26 nighty-- joined
11:27 bjz joined
11:28 ertes-w joined
11:28 abhiroop joined
11:30 sfcg joined
11:33 ertes-w joined
11:33 abhiroop joined
11:34 <quchen> Is Alex Thiemann here? (Or his father, or any of the Freiburg ogas)
11:34 Levex joined
11:34 a3Dman joined
11:34 a3Dman joined
11:36 mrkgnao joined
11:37 xificurC joined
11:39 sdothum joined
11:39 Wizek__ joined
11:40 ExpHP joined
11:40 cschneid_ joined
11:41 fendor joined
11:42 <Myrl-saki> Is it only me, or are build times wayyyy slower in ghcjs?
11:44 xcmw joined
11:46 asthasr joined
11:49 erikd joined
11:49 xificurC joined
11:51 fendor joined
11:53 fendor joined
11:57 fizruk joined
11:57 bartavelle joined
11:57 butterthebuddha joined
12:00 nomicflux joined
12:00 qqwy joined
12:00 Guest45040 joined
12:01 <Guest45040> anyone online?
12:01 <cocreature> Guest45040: just ask your question directly and stack around for a while :)
12:02 <Guest45040> okay
12:02 <ongy> is it also possible to cabal around? :)
12:03 <Guest45040> how can i change my name im new in irc
12:03 <cocreature> ongy: heh, typing is hard :)
12:03 <ongy> /nick <newnick>
12:03 Amadiro joined
12:03 <Whoamii> thanks
12:03 xtreak joined
12:04 Yuras joined
12:04 sepp2k joined
12:04 chlong joined
12:04 xtreak joined
12:04 Pip_ joined
12:06 jutaro joined
12:07 mstruebing joined
12:08 bjz_ joined
12:12 doomlord joined
12:13 roconnor joined
12:13 blym_ joined
12:13 Gloomy joined
12:13 sampuka joined
12:13 Naga31 joined
12:15 erikd joined
12:16 jorj joined
12:18 nilof joined
12:21 danthemyth joined
12:21 raichoo joined
12:21 <ongy> yo
12:21 <ongy> ahh, wrong chat :/
12:22 tromp joined
12:22 blym_ joined
12:22 m1dnight1 joined
12:24 obadz joined
12:24 redeemed joined
12:25 nirvinm joined
12:26 ogrady joined
12:29 ExpHP joined
12:34 <hvr> cocreature: "stack around"? :-)
12:34 abhiroop joined
12:35 <* hvr> .oO( http://www.smartplay.us/ingenio/images/ablocks_03.jpg )
12:36 halogenandtoast joined
12:36 Gloomy joined
12:37 oisdk joined
12:39 bjz joined
12:41 blym_ joined
12:41 <xificurC> I'll give this one more go here - is there some sort of summary (or can someone summarize here) the state of haste, ghcjs and purescript regarding - completeness, maintenance, userbase, packages, using js packages, FFI, resulting size? These are some of the important things that come out of the top of my head but it takes a while to look for answer
12:41 <xificurC> s on each of them for each implementation. I'm lazy :)
12:42 <cocreature> hvr: in my defence, I use a weird keyboard layout where 'a' and 'i' are right next to each other :)
12:42 <quchen> cocreature: \/{}*?()-:@?
12:42 <quchen> uiaeosnrtdy
12:42 <cocreature> quchen: I guess I’m not the only one using that layout :P
12:43 <quchen> I tried, but couldn’t do it. I use the 3rd layer with QWERTZ
12:43 <quchen> Never looked back
12:43 <quchen> Wish I could type Neo though, but the pain of learning it (fluently) is huge
12:44 <cocreature> quchen: add layer 4, 5 and 6 to that and you have the important parts of neo :)
12:44 <quchen> Come to think of it, I could make Neo my IRC layout
12:45 <quchen> Jeez that took long to type
12:45 jeltsch joined
12:45 zcourts joined
12:45 <quchen> 5 and 6 are nonsense
12:46 <quchen> 4 … maybe, one day
12:46 <cocreature> 5 and 6 are great if you need to type math
12:47 zcourts joined
12:49 Destol joined
12:50 <quchen> Which nobody ever does outside of LaTeχ
12:50 <cocreature> I often take notes outside of latex
12:51 <quchen> Plus it’s incredibly annoying to watch someone struggle with Neo instead of using Agda’s mode because of reasons
12:51 <quchen> The only thing words is watching Vim users trying to find and open a file.
12:51 <quchen> s/words/worse/
12:52 <quchen> Anyway, I’m not a fan of the 5th and 6th layer. :-)
12:53 <cocreature> fair enough :)
12:53 n1k joined
12:53 jao joined
12:53 Gurkenglas_ joined
12:53 zeroed_ joined
12:54 logicmoo joined
12:54 cur8or_ joined
12:54 Anonymous0250_ joined
12:54 <NinjaTrappeur> quchen: CTRL-p CTRL-f and done ;)
12:55 xcmw_ joined
12:55 eklavya_ joined
12:55 hucksy joined
12:56 lc_ joined
12:56 mstruebi1 joined
12:57 watabou joined
12:57 acarrico joined
12:58 takuan_dozo joined
12:58 hc_ joined
12:58 brynedwards joined
12:58 kav_ joined
12:58 pfoetche1 joined
12:58 thunderrd joined
12:59 ilyaigpetrov joined
12:59 a3Dman joined
12:59 RGamma_ joined
13:01 CaptainProton joined
13:01 xxalien8dxx joined
13:01 litchblde joined
13:01 mniip_ joined
13:02 eviltwin_b joined
13:02 hurkan1 joined
13:02 t00m0 joined
13:03 netheranthem joined
13:03 leothrix joined
13:03 bweston92 joined
13:04 robertkennedy joined
13:04 augur joined
13:05 jer1 joined
13:05 rcat joined
13:06 fosterite joined
13:06 halogenandtoast joined
13:07 cloudhead joined
13:08 alien8 joined
13:08 m1dnight1 joined
13:09 ThomasLocke joined
13:09 ludat joined
13:09 sampuka joined
13:09 yrid joined
13:10 ziocroc2 joined
13:10 spacecadetbrown joined
13:10 sepp2k joined
13:11 mizu_no_oto_work joined
13:12 mda1 joined
13:13 chu joined
13:13 Soft joined
13:14 Yuras joined
13:14 mohsen_ joined
13:14 gmcabrita joined
13:14 jship joined
13:14 kritzcreek joined
13:14 ccomb joined
13:14 freusque joined
13:14 danvet joined
13:14 fluffystub joined
13:14 dwarders joined
13:14 bitonic joined
13:14 vikram__________ joined
13:14 zpconn__________ joined
13:14 bytesighs joined
13:14 usr joined
13:14 jophish joined
13:16 tromp joined
13:17 Ciquattro joined
13:17 blym_ joined
13:18 mnoonan joined
13:18 JeanCarloMachado joined
13:19 JagaJaga joined
13:20 <greymalkin> I find myself doing something like `maybe (fail $ "message") return` a lot these days. Hoogle hasn't shown me any cleaner way to do this.
13:20 jeltsch joined
13:20 Boomerang joined
13:21 oish joined
13:22 systadmin joined
13:23 a3Dman joined
13:24 cpennington joined
13:26 freusque joined
13:26 kritzcreek joined
13:26 systadmin joined
13:26 gmcabrita joined
13:26 danvet joined
13:27 ccomb joined
13:27 dwarders joined
13:27 jship joined
13:27 zpconn__________ joined
13:27 ystael joined
13:27 usr joined
13:27 usr joined
13:27 bytesighs joined
13:27 vikram__________ joined
13:27 fluffystub joined
13:27 bitonic joined
13:28 ChristopherBurg joined
13:28 Yuras joined
13:29 danthemyth joined
13:30 soniku joined
13:31 tsmish joined
13:31 JeanCarloMachado joined
13:32 Benzi-Junior joined
13:34 coltfred joined
13:35 iAmerikan joined
13:35 fendor joined
13:36 <NickHu> Anybody got any advice for debugging segfaults?
13:37 plutoniix joined
13:37 <c_wraith> depends on the source.
13:37 <ertes-w> greymalkin: maybe (throwIO (userError "message")) pure -- this way is cleaner, but i'm pretty sure that's not what you're looking for =)
13:38 jangsutsr joined
13:38 plutoniix joined
13:38 zeroed joined
13:38 <c_wraith> ertes-w: it's also only correct if it's in IO. What if greymalkin was talking about some other context where fail is defined sensibly?
13:39 joseCova joined
13:40 Boomerang joined
13:40 ExpHP joined
13:40 <ertes-w> s/throwIO/throwM/
13:40 <ertes-w> from 'exceptions'
13:40 <ertes-w> at least until we finally get MonadFail
13:41 `^_^v joined
13:41 alif_bae joined
13:42 meba joined
13:45 jathan joined
13:45 robotroll joined
13:45 iulian joined
13:46 texasmynsted joined
13:47 eacameron joined
13:48 moongazer joined
13:48 DrMentats joined
13:48 Argue_ joined
13:50 plutoniix joined
13:50 JeanCarloMachado joined
13:51 ExpHP joined
13:53 OnkelTem joined
13:55 alif joined
13:56 ADG joined
13:56 alif joined
13:56 <ADG> how to remove "stack" if I installed via "https://get.haskellstack.org/" (sh) - Ubuntu 16.04 64 bit
13:57 Tibo joined
13:57 jutaro joined
13:58 watabou joined
13:58 plutoniix joined
13:59 zariuq joined
14:00 <mekeor> ADG: maybe this helps? https://docs.haskellstack.org/en/stable/faq/#how-do-i-reset-remove-stack-such-as-to-to-do-a-completely-fresh-build
14:00 <mekeor> ADG: where is the stack binary you are using located? (`which stack`)
14:00 splanch joined
14:00 <ADG> usr/local/bin/stack
14:01 <ADG> I removed ~/.stack but still stack command works
14:01 <cocreature> remove the binary
14:01 takle joined
14:01 fendor joined
14:02 <cocreature> the stack binary should be statically linked so it really should just be that one binary (plus dotfiles in .stack)
14:02 <ADG> that is ok, so now I should also have remove it from bash entry or something?
14:03 plutoniix joined
14:05 <c_wraith> I mean.. if you've removed the binary, bash won't be able to run it.
14:06 crobbins joined
14:07 pranitbauva1997 joined
14:07 xiinotulp joined
14:09 JCGrant[m] joined
14:10 Noldorin joined
14:11 refold joined
14:12 crave joined
14:13 xiinotulp joined
14:15 thunderrd_ joined
14:18 ADG joined
14:19 eschnett joined
14:20 sgronblo joined
14:21 cpennington joined
14:22 xiinotulp joined
14:23 <greymalkin> ertes-w: Fail is just the shortest IRC line; I'm actually using throwM in most cases, but having to repeat the `pure` at the end feels hacky, and I'm on the edge of just making a `guardJust` function which takes the error type and the maybe value.
14:23 cschneid_ joined
14:23 gaze__ joined
14:23 <ertes-w> greymalkin: well, you could just use throwM without doing the Maybe roundtrip
14:24 <ertes-w> greymalkin: or use Alternative instead of Maybe
14:25 sfcg joined
14:25 <mrkgnao> is there any way to get overloaded numeric literals for non-Num types?
14:25 <ADG> running "$ stack upgrade" is stuck on "Fetching package index ... ", is it normal (takes much time?)
14:25 <greymalkin> ertes-w: Interfacing with other libraries, though, so that's not quite an option for most of my cases.
14:25 <MarcelineVQ> it can take awhile the first time
14:25 <mrkgnao> for instance, can I get 0 to be interpreted as a Monoid a => a?
14:26 <ertes-w> greymalkin: if all else fails just write your own utility function
14:26 <cocreature> mrkgnao: RebindableSyntax allows you to provide your own fromInteger function
14:26 <mrkgnao> oh?
14:26 <mrkgnao> oh?!
14:26 <MarcelineVQ> or if you deleted .stack/indices/ it has to get it fresh
14:27 <ertes-w> greymalkin: at the caveat that it makes your code less direct and thus harder to follow
14:27 <mrkgnao> cocreature: I am so happy right now. always assumed that was one place that GHC went "okay, this is final"
14:27 <glguy> the initial download is around 240mb
14:28 <ADG> my ~/.stack was empty I removed it
14:28 <cocreature> mrkgnao: imho it’s kind of an ugly extension since just replacing builtin syntax can be confusing but it’s nice that it’s possible
14:28 <ADG> 240MB, fuck~ can I get a progress bar?
14:29 <Cale> mrkgnao: Don't *actually* do that.
14:29 drcode joined
14:29 fendor joined
14:30 <cocreature> Cale: overloaded integer literals is the only use of RebindableSyntax that is at least close to being reasonable :)
14:30 <Cale> I suppose
14:30 <mrkgnao> cocreature, Cale: I'm just playing around with something subhask-ish. doing this in anything remotely close to being used practically would be ... interesting.
14:30 _sg joined
14:30 <mrkgnao> I guess it's better than partial Num instances that only match one fromInteger pattern :)
14:32 jerme joined
14:33 rkazak joined
14:34 xiinotulp joined
14:35 systadmin joined
14:35 HarveyPwca joined
14:36 Costar joined
14:36 dfranke joined
14:36 drcode joined
14:38 xiinotulp joined
14:40 coltfred joined
14:40 baldrick2 joined
14:41 xiinotulp joined
14:44 buttbutter joined
14:44 xiinotulp joined
14:46 fotonzade joined
14:46 xiinotulp joined
14:47 mizu_no_oto joined
14:50 jeltsch joined
14:50 xiinotulp joined
14:52 saep joined
14:52 theelous3 joined
14:53 prophile joined
14:53 oisdk joined
14:54 acowley2 joined
14:54 unyu joined
14:55 xiinotulp joined
14:56 ertes joined
14:59 watabou joined
15:00 dcoutts joined
15:00 halogenandtoast joined
15:01 a3Dman joined
15:01 xiinotulp joined
15:02 takle joined
15:03 splanch joined
15:03 xiinotulp joined
15:06 xiinotulp joined
15:07 balor joined
15:08 tromp joined
15:09 peterbecich joined
15:09 flatmap13 joined
15:10 aweinstock joined
15:11 eklavya joined
15:12 alqatari joined
15:14 sgronblo joined
15:14 xiinotulp joined
15:14 pera joined
15:15 dcoutts_ joined
15:15 RegEchse joined
15:16 hackebeilchen joined
15:16 uglyfigurine joined
15:18 burtons joined
15:20 augur joined
15:21 oisdk joined
15:21 eazar001 joined
15:22 xiinotulp joined
15:23 iulian_ joined
15:24 fosterite joined
15:24 skeet70 joined
15:25 alif_bae joined
15:25 xiinotulp joined
15:25 jmelesky joined
15:26 <nshepperd_> If you use RebindableSyntax there it will apply to all numeric literals though
15:26 <nshepperd_> Not just 0
15:29 crave joined
15:30 alif joined
15:30 <nshepperd_> So whatever you do we'll probably be partial if you don't have a good definition for 1
15:30 sw1nn joined
15:30 <qqwy> Guys, when a piece of Haskell code compiles, what is left of the types? Do values of a type contain a vpointer to the type's typeclass implementations?
15:30 <qqwy> How does Haskell know at runtime what type a value has?
15:31 cschneid_ joined
15:31 <EvanR> it doesnt
15:31 <Sornaensis> I don'
15:31 <Sornaensis> t know about interpreted
15:31 <EvanR> and doesnt need to
15:31 <Sornaensis> but haskell code has the types erased
15:31 <Sornaensis> after compilation
15:32 ragepandemic joined
15:32 <qqwy> Does someone know where to find more information about this?
15:32 noam joined
15:32 <qqwy> I've been browsing the GHC webpages for the last 30 minutes
15:32 <EvanR> for type class implementations, you can think of constraints as being extra arguments which point to the record of class implementations
15:32 <Sornaensis> the purpose of a strict and static type system is that once the application is compiled you do not care what the types are at runtime
15:33 <qqwy> Thank you, Sornaensis
15:34 <qqwy> for confirming my gut feeling
15:34 <EvanR> qqwy: in machine code, you dont check what the type of something is before doing the instructions, you just assume
15:34 <qqwy> Someone was comparing OCaml and Haskell in a rather unfair way
15:34 kazagistar joined
15:34 <Sornaensis> type erasure is common to most compiled languages
15:34 <EvanR> and either hope youre right, or you have a proof youre right, which is what a type system does
15:35 <nshepperd_> qqwy: Num a => a -> a is compiled into Num a -> a -> a
15:35 <Sornaensis> qqwy: in what way
15:36 <qqwy> EvanR: C++'s object-orientation constructs work with a dynamic vtable pointer. I guess this is mostly the case because a piece of compiled code might be linked into by another piece of code that inherits one or multiple of those classes.
15:36 xiinotulp joined
15:36 <EvanR> that is how haskell works too
15:36 <qqwy> (Not counting CRTP-style OOP)
15:36 <nshepperd_> The Num a value is a record type containing all the Num functions for that type, and is passed as a normal parameter
15:36 <EvanR> see nshepperd_'s post
15:36 <qqwy> Ah!
15:36 <EvanR> its just not called a vtable
15:36 tromp joined
15:36 <qqwy> So 'Num a' is passed around as extra construct
15:37 <qqwy> extra argument*
15:37 <EvanR> in the worst case yeah
15:37 <nshepperd_> If your code is monomorphic, that is usually inlined and nothing will even be passed
15:37 <qqwy> wonderful, I see! :D
15:37 raichoo joined
15:40 <EvanR> that reading of Num a => a -> a seems really far from whatever the types are supposed to mean denotationally... i wonder why it never came up when i was learning haskell. seems like a great way to explain haskell to a C++er
15:40 <EvanR> i wonder if its a big coincidence
15:41 xiinotulp joined
15:42 <nshepperd_> Well, -> and => are both implication arrows in curry Howard. If a, then b
15:43 trism joined
15:44 <EvanR> but with => your supposed to think "will check if and only if for your choice of a theres a unique choice of Num"
15:44 <nshepperd_> But => has some restrictions that make is more like witnessing a "fact", such as instance coherence
15:44 <EvanR> which seems difference
15:45 <nshepperd_> "Num a" is a fact that has a unique proof
15:45 <Lokathor> in a haskell type, => can be read as "allows"
15:45 <Lokathor> (though that's not the only word you could stick there)
15:45 rkazak joined
15:46 <EvanR> erm
15:46 <EvanR> doesnt really capture the reverse uniqness
15:46 insitu_ joined
15:46 <Lokathor> reverse uniqueness?
15:46 <EvanR> which agda and idris dropped, so it really is just like ->
15:46 HoierM joined
15:47 HoierM joined
15:48 <nshepperd_> instance coherence means that the compiler can thread these implicit arguments around for you, since there's only one possible choice of argument
15:48 xiinotulp joined
15:48 HoierM joined
15:49 insitu joined
15:49 splanch_ joined
15:49 lambdaman joined
15:49 HoierM joined
15:49 PennyNeko joined
15:50 HoierM joined
15:50 splanch__ joined
15:51 Luke joined
15:51 oisdk joined
15:51 HoierM joined
15:52 HoierM joined
15:53 splanch joined
15:53 xiinotulp joined
15:53 HoierM joined
15:54 HoierM joined
15:55 cyborg-one joined
15:56 HoierM joined
15:56 splanch_ joined
15:56 cpennington joined
15:56 latro`a joined
15:56 HoierM joined
15:57 <mrkgnao> nshepperd_: I know, I've been trying to figure out if something sneaky can be done to dynamic-ish-ly select the typeclasses, i.e. a multiplicative monoid for 1 and an additive monoid for 0
15:57 splanch__ joined
15:57 HoierM joined
15:58 xiinotulp joined
15:58 electrostat joined
15:58 HoierM joined
15:58 <mrkgnao> there must be some way using reflection, but ... "'tis a silly place", etc
15:59 HoierM joined
15:59 watabou joined
16:01 splanch joined
16:01 HoierM joined
16:01 ragepandemic joined
16:01 mada joined
16:02 insitu joined
16:02 lavalike joined
16:02 splanch_ joined
16:02 HoierM joined
16:03 tomphp joined
16:03 HoierM joined
16:04 HoierM joined
16:05 HoierM joined
16:06 MoALTz joined
16:06 HoierM joined
16:08 Sonolin joined
16:08 Shock_ joined
16:08 HoierM joined
16:08 sgronblo joined
16:09 xiinotulp joined
16:09 fizruk joined
16:09 urodna joined
16:09 msks joined
16:10 xiinotulp joined
16:10 HoierM joined
16:11 <qqwy> Thank you, EvanR, nshepperd_ and Lokathor
16:11 <qqwy> :-)
16:11 mmachenry joined
16:11 robotroll joined
16:12 xiinotulp joined
16:12 msks joined
16:12 simukis joined
16:12 msks joined
16:12 acertain joined
16:13 meandi_2 joined
16:13 noffle joined
16:13 blym joined
16:15 kmels joined
16:15 ragepandemic joined
16:16 xiinotulp joined
16:17 justin2 joined
16:17 bvad joined
16:19 xiinotulp joined
16:21 tomphp joined
16:22 xiinotulp joined
16:22 JoshS joined
16:23 Hjulle joined
16:23 dm3 joined
16:23 gehmehgeh joined
16:25 darlan joined
16:25 twomix joined
16:25 Einwq joined
16:27 tomphp joined
16:28 xiinotulp joined
16:30 splanch joined
16:30 iAmerikan joined
16:31 t4nk411 joined
16:31 joseCova joined
16:32 WhiskyRyan joined
16:32 jmelesky joined
16:32 <Hjulle> Does the function "\f x -> fmap ($x) f :: Functor f => f (a -> b) -> a -> f b" have a name? It is useful for writing things like "f <$> pure a <*> b <*> pure c <*> pure d" without needing to flip the order of the arguments or needlessly requiring Applicative.
16:32 xiinotulp joined
16:34 ragepandemic joined
16:34 umib0zu joined
16:37 <byorgey> Hjulle: no
16:37 <ski> Hjulle : it has been called .. `flip'
16:37 eklavya_ joined
16:37 <byorgey> ski: ?
16:38 <byorgey> oh, I get it, it's a generalized flip
16:38 <ski> lambdabot had that type for `flip', for some time
16:38 wildlander joined
16:38 <byorgey> @let flip' f x = fmap ($x) f
16:38 <lambdabot> Defined.
16:38 Luke joined
16:38 <byorgey> > flip' (-) 3 5
16:38 <lambdabot> 2
16:39 <Hjulle> ah, nice.
16:39 <byorgey> > flip' [(+1), (*3), const 8] 2
16:39 <lambdabot> [3,6,8]
16:39 eklavya_ joined
16:39 replay joined
16:39 WhiskyRyan joined
16:39 DocWinter joined
16:40 <byorgey> I'm not sure I like that name though. The name is too tied to the ((->) a) instance and IMO doesn't really give much intuition for what it does in general.
16:40 <ski> iirc, i've also seen this operation in a paper
16:40 hackebeilchen joined
16:40 <Hjulle> I was thinking about something like <*$>, but that looks ugly.
16:40 <ski> (can't recall how it was called or notated)
16:41 xiinotulp joined
16:41 alx741 joined
16:42 <Hjulle> I also tried searching hoogle, but that only gave me fmap, <*>, etc., that do not have the correct type. Why is hoogle's type search so fuzzy?
16:44 <starmix> exit
16:44 xiinotulp joined
16:44 <starmix> oops sorry
16:44 <byorgey> Hjulle: because sometimes you don't know the precise type you want, and fuzzy type search is useful.
16:45 <byorgey> or sometimes you think you know what type you want, but there is actually something more general that will work.
16:45 <Hjulle> byorgey: I'm fine with more general, but not with types that don't match at all.
16:46 mmn80 joined
16:47 xiinotulp joined
16:48 alx741 joined
16:48 bungoman joined
16:48 viper97 joined
16:49 afarmer joined
16:49 <viper97> totally new to haskell. any good books?
16:49 ragepandemic joined
16:51 <monochrom> Graham Hutton's textbook. RIchard Bird's textbook. Chris Allen's textbook.
16:53 bitemyap1 joined
16:53 viper97 joined
16:53 uglyfigurine joined
16:54 connrs joined
16:55 lc_ joined
16:56 fowlslegs joined
16:57 lambdama_ joined
16:58 bigos_ joined
16:59 tromp joined
16:59 mivael left
17:00 chaosmasttter joined
17:00 codesoup joined
17:00 mivael joined
17:00 mmachenry1 joined
17:00 danthemyth joined
17:01 sfcg joined
17:02 sgronblo joined
17:03 mda1 joined
17:04 <tabaqui> I'm receiving messages from my program:
17:04 <tabaqui> ProgName: unable to decommit memory: Invalid argument
17:04 <tabaqui> what does it mean?
17:05 <tabaqui> I've found bug in old version ghc, but it was closed few years ago
17:05 oish joined
17:05 <monochrom> Yes, this is a known issue, but it only happens when the program exits, it is considered no harm but will be fixed next time.
17:05 <tabaqui> oh, that's fine then
17:05 <monochrom> Let me think where I read about it.
17:06 zzz joined
17:06 jason85 joined
17:06 flatmap13 joined
17:07 ludat joined
17:07 <monochrom> At program exit, the run time system calls a deallocation syscall, and the syscall didn't like the parameter. (Not sure who's fault.)
17:07 <cocreature> tabaqui: are you using 8.0.1? I vaguely recall seeing that 8.0.2 fixes this at least in some circumstances
17:07 sgronblo joined
17:07 flatmap13 joined
17:08 <tsahyt> how can I run ghci through stack with rts options? stack ghci -- +RTS .. doesn't work
17:08 <tsahyt> oh nvm, --ghc-options
17:09 <cocreature> tsahyt: you might need --ghci-options
17:09 noffle left
17:09 <cocreature> but tbh I’m not sure what exactly the difference between those is
17:09 BlueRavenGT joined
17:09 epsilonhalbe joined
17:09 <cocreature> ah --ghc-options applies to both
17:09 <cocreature> I should just read --help :)
17:09 epsilonhalbe left
17:09 <tabaqui> cocreature: I compile it with 8.0.2, but run on other machine
17:09 <tsahyt> hmm, neither actually works
17:09 <Gurkenglas> Hjulle, https://hackage.haskell.org/package/distributive-0.5.2/docs/Data-Distributive.html#v:distribute
17:10 rkazak joined
17:10 <tabaqui> cocreature: stack lts-8.9
17:10 [[[[[ExTRa]]]]] joined
17:11 <Gurkenglas> Hjulle, also "f <$> pure a <*> b <*> pure c <*> pure d" is "f a <$> b <*> pure c <*> pure d"
17:12 <cocreature> tabaqui: I think https://ghc.haskell.org/trac/ghc/ticket/12865 is the fix. judging from that ticket it’s only in 8.2 so maybe my memory is wrong here and it’s not fixed in 8.0.2
17:12 <Gurkenglas> Hjulle, http://hackage.haskell.org/package/lens-4.15.2/docs/Control-Lens-Lens.html#v:-63--63-
17:12 <Hjulle> Gurkenglas: Thanks
17:13 <Hjulle> Gurkenglas: Yes, I know, but that doesn't solve the problem with c and d.
17:13 <cocreature> tabaqui: the good news is, 8.2 should be out relatively soon (1-2 months is probably realistic)
17:13 xtreak joined
17:14 <tabaqui> cocreature: but our team will release in three weaks)
17:14 <tabaqui> *weeks
17:14 NeverDie joined
17:14 <cocreature> tabaqui: well as monochrom said it’s mostly harmless
17:15 <Hjulle> Gurkenglas: The last one was exactly what I was looking for and the first one is a cool generalisation. :)
17:15 <tabaqui> btw, bug with hWaitForInput is still open
17:15 iAmerikan joined
17:15 <tabaqui> I thought it will be fixed in April and I can use it soon
17:16 ziyourenxiang joined
17:16 sleffy joined
17:16 ziyourenxiang joined
17:17 carlomagno joined
17:17 dm3 joined
17:18 {emptyset} joined
17:19 Twey joined
17:20 mizu_no_oto joined
17:21 ziyourenxiang joined
17:21 BartAdv joined
17:22 eklavya joined
17:22 dm3 joined
17:23 anishathalye joined
17:23 argent0 joined
17:23 extra- joined
17:24 Wizek__ joined
17:24 Mon_Ouie joined
17:25 Gloomy joined
17:27 Swizec joined
17:28 Swizec joined
17:29 freeman` joined
17:29 ubsan_ joined
17:30 xormor joined
17:32 dfeuer joined
17:33 fotonzade joined
17:34 MDA2 joined
17:34 mmachenry joined
17:35 mvxtnobeb joined
17:38 jangsutsr joined
17:38 pera joined
17:39 replay joined
17:40 xall_ joined
17:40 leat joined
17:40 jbgi joined
17:40 JuanMiguel joined
17:40 Hexagenic joined
17:40 Aku joined
17:40 zcourts joined
17:44 tomphp joined
17:44 anishathalye joined
17:44 anishathalye joined
17:45 blym_ joined
17:45 anishathalye joined
17:50 LordBrain joined
17:50 anishathalye joined
17:52 blym_ joined
17:54 dm3 joined
17:55 alif joined
17:55 sellout- joined
17:55 tomphp joined
17:55 connrs joined
17:55 freusque joined
17:56 sfcg joined
17:56 pranitbauva1997 joined
17:57 cdg joined
17:57 buttbutter joined
17:59 cschneid_ joined
18:01 ccomb joined
18:01 ph88^ joined
18:02 flatmap13 joined
18:03 Dione joined
18:03 moongazer joined
18:03 Dione left
18:04 istvan joined
18:05 reliability joined
18:06 sfcg joined
18:07 steeze joined
18:09 zcourts_ joined
18:10 tromp joined
18:10 blym_ joined
18:11 jsgrant_om joined
18:12 lambdaman joined
18:12 augur joined
18:15 yrdz joined
18:16 unyu joined
18:16 Shatnerz joined
18:17 fosterite joined
18:19 <Gurkenglas> stack unpack has nothing to do with the git projects the maintainers use, right? Can stack help me make pull requests to libraries?
18:19 a3Dman joined
18:19 zcourts joined
18:19 ckubrak joined
18:19 mizu_no_oto joined
18:19 raichoo joined
18:20 Luke joined
18:20 blym_ joined
18:20 taktoa joined
18:21 coot joined
18:22 peterbecich joined
18:22 dddddd joined
18:24 matthewbauer joined
18:25 <cocreature> Gurkenglas: I don’t think there is something like "stack unpack" that clones the source-repository. ofc you can just manually search for it and build it using stack so in that sense stack can help but it has no specific functionality for prs
18:25 ckubrak joined
18:27 prkc joined
18:30 blym_ joined
18:30 uglyfigurine joined
18:33 deank joined
18:33 mjora7 joined
18:34 <jle`> 'stack unpack' is a command
18:34 <jle`> oh but yeah it doesn't do that
18:34 mkoenig_ joined
18:34 HarveyPwca joined
18:35 mojjo joined
18:35 iAmerikan joined
18:36 <mojjo> hi!! is there anyone who could help me out with some simple aeson parsing?
18:36 <cocreature> mojjo: just ask your question directly and stick around for a bit :)
18:37 <mojjo> I'm basicall trying to parse the keys of a json object into a list of strings, I think it's not possible to derive that.
18:37 a3Dman joined
18:38 <jle`> you can just parse your json string into an Object
18:38 <jle`> and then get the keys
18:38 carlomagno joined
18:38 <EvanR> after you have an Object, getting the keys is a regular function, of the HashMap
18:38 <jle`> you could even parse it as a regular ol Data.Map
18:38 xauth joined
18:39 <cocreature> converting to a different map type just to extract the keys seems a bit overkill
18:39 <jle`> it'd just be `fmap M.keys . decode`
18:40 <jle`> fmap M.keys . decode :: ByteString -> Maybe [String]
18:40 <mojjo> jle' alright, I'll try your suggestion...
18:40 <jle`> maybe [] M.keys . decode :: ByteString -> [String]
18:40 <cocreature> jle`: right but it’s just as simple if you use M.keys where M=Data.HashMap :)
18:40 <jle`> yeah heh. there's really no reason to prefer one over the other
18:40 joe9 joined
18:40 freusque joined
18:41 <jle`> hashmap might be slightly more performant for this
18:41 <jle`> but from an API perspective there is no difference
18:41 <cocreature> right, I was talking about performance/unnecessary conversions
18:41 <jle`> ah
18:41 <jle`> operational junk
18:42 <cocreature> it probably doesn’t matter but since the API is the same, just use the potentially faster one :)
18:42 tomphp_ joined
18:43 <EvanR> is there binding form like do notation where after i bind whatever variables, i "finalize" by entering an expression that uses the variables, but i cant continue on like do notation
18:43 zcourts joined
18:43 <jle`> applicative do ?
18:43 <monochrom> an inner do block.
18:44 <EvanR> i can continue on after an inner do block
18:44 <EvanR> hmm applicative do
18:44 zeroed joined
18:44 <monochrom> oh, that kind of "continue"
18:44 <EvanR> also inner do is irrelevant
18:44 <EvanR> the final expression isnt necessarily a monad
18:44 <jle`> but you can't force a do block to be applicative-only if you have a specific type tho
18:45 <monochrom> let-in
18:45 JeanCarloMachado joined
18:45 <EvanR> like exp(x), exp(y), exp(z) |- final(x,y,z)
18:46 <EvanR> oh ok let... *thinks*
18:46 solidsalvia joined
18:46 <cocreature> "let x = expx; y = expy; z = expz in final <$> x <*> y <*> z"
18:47 <EvanR> uh huuuuuh....
18:47 <monochrom> Or maybe it's just final x y z
18:47 <cocreature> I’m not sure I really understand your question tbh
18:47 <monochrom> I mean at this point the question has become vague enough that any truism is a legit answer.
18:48 <mojjo> jle`: I could parse the json to `Maybe Object`, I'm still wondering how to acces the keys. fmap over Object maps over its values..
18:48 <EvanR> all this is literally answering my question
18:48 insitu joined
18:49 <EvanR> so like, could x cause a non deterministic computation, y cause a quit-early, ...
18:49 <cocreature> mojjo: you fmap over "Maybe Object"
18:49 <cocreature> mojjo: or just pattern match and don’t fmap in the Just case
18:49 <EvanR> probably
18:49 <cocreature> EvanR: depends on the Applicative instance
18:50 zcourts joined
18:50 <EvanR> seems like list monad with just applicative notation
18:50 hylo joined
18:50 <cocreature> EvanR: for "Either a", a Left would cause a quit-early
18:50 <monochrom> Do you actually have an example x, example y, and example final?
18:50 alfredo joined
18:50 prkc joined
18:51 <EvanR> if x is an object of class X, and y is true in the context, and z is some unique object (if it exists), then f(x,y,z) occurs
18:51 <EvanR> so this potentially does nothing, or does something for each x
18:52 connrs joined
18:52 <monochrom> No I mean actual code.
18:52 <EvanR> no
18:52 <cocreature> EvanR: you got me interested. what are you working on?
18:53 <EvanR> video games
18:53 <cocreature> huh, what do you use that for in a video game? rules that define how game state progresses?
18:54 <EvanR> the rules of inferences are the rules of the game, the axioms are the starting position
18:54 henriksod joined
18:55 <mojjo> cocreature: ok, concretely, say : `x = decode $ "{\"key1\":\"\"}" :: Maybe Object` then x is `Just (fromList [("key1",String "Dave")])`. How to get/pattern match the "key1" out of the structure?
18:55 <monochrom> Then I am not convinced that "can't continue" is true.
18:55 <LordBrain> i had an idea occur to me yesterday, that a videogame could be used to teach haskell.
18:55 <monochrom> But meh, I don't even know what's "continue".
18:55 <mojjo> cocreature: (the Dave string is a typo)
18:55 <EvanR> i did something like this in this video https://www.youtube.com/watch?v=p1xUViqtYFA but i used monads to say these phrases, and it worked but really its a little weird
18:56 <cocreature> mojjo: case decode … of Just obj -> Map.keys obj; Nothing -> handleParseFailure
18:56 kamyar joined
18:57 <kamyar> Hello friends!
18:57 argent0 joined
18:57 <kamyar> Can we write this better: (||) <$> Just True <*> Just False
18:57 <kamyar> I wanna use infix notation if possible
18:57 <monochrom> consider "liftA2 (||) xxx yyy"
18:58 <kamyar> Note that the real code is not so easy!
18:58 <cocreature> > let (|||) = liftA2 (||) in Just True ||| Just False
18:58 <lambdabot> Just True
18:58 <monochrom> If you want infix, create your own infix operator and define it to be liftA2(||)
18:58 <cocreature> but I wouldn’t call that better
18:58 <monochrom> Yeah, it's only the first step towards better.
18:59 <monochrom> To complete the journey, create your own infix operator.
18:59 <kamyar> IN real code True and Flase are expressions
18:59 <monochrom> WE KNOW
18:59 <* cocreature> removes monochrom’s capslock license
18:59 <Tuplanolla> Technically they're always expressions...
18:59 <glguy> cocreature: he's going to need that back to turn it off...
19:00 tromp joined
19:00 <cocreature> glguy: oh right
19:00 <* cocreature> hands it back
19:01 <monochrom> haha
19:01 <kamyar> Here is my real code: http://lpaste.net/355245
19:02 Einwq joined
19:02 nh2 joined
19:03 <monochrom> My answer stands.
19:03 <mojjo> cocreature: had to parse directly to `Maybe (Map String String)` in order to get it done.. nice..
19:04 <cocreature> kamyar: I made an annotation
19:04 matthewbauer joined
19:05 <EvanR> cocreature: so... objectOfClass :: Class a -> Ante a, isTrue :: (Context -> Bool) -> Ante (), onEvent :: Event b -> Ante b, and f could be :: a -> () -> b -> Consequent. the applicative combination would be Ante Consequent which has interpretation ???
19:06 <greymalkin> Is there a non-deprecated way to do something like the following? newtype Currency currency => Money currency = Money Scientific
19:06 <MitchellSalad> greymalkin: yeah, put the constraint on all the functions involving Money, but not the data type itself
19:06 <kamyar> cocreature: Thnx really!
19:07 <c_wraith> > let x <^ f = (fmap f x <*>) ; (^>) = id in Just 1 <^(+)^> Just 2 -- kamyar
19:07 <lambdabot> Just 3
19:07 <LordBrain> greymalkin, are you using an existential envelope in this code?
19:07 <c_wraith> kamyar, but don't really do that. :)
19:08 <kamyar> cocreature: Your annotation worked!
19:08 cyborg-one joined
19:08 <LordBrain> greymalkin, i mean like dynamic... where you get the type variable omitted on the left side, so that you postpone the type error...
19:09 <cocreature> LordBrain: that syntax is DataTypeContexts and doesn’t exist anymore
19:09 <monochrom> c_wraith: That's cute!
19:09 <cocreature> or is at least deprecated I don’t remember
19:10 <LordBrain> i brought it up because when i have wanted to reach for things in the past, i was doing something similar
19:10 <c_wraith> monochrom, it kinda looks like a Kirby variant, too. :)
19:10 <mojjo> now, I'm facing the bit more complex parsing task: `{"key1":"abc", "key2": ["abc","abc"]}` Unfortunately aeson cannot just parse this to `Maybe (Map String (Either String [String]))` Does anyone have a hint how to archive this?
19:11 <monochrom> mojjo: This is why Map String String is a bad idea. Go back to Object which is Hashmap Text Value. There is a reason it's Value.
19:11 <EvanR> if thats the type you want, you can implement it with the json parser monad
19:11 <EvanR> oh if you just want the keys, then yeah, HashMap
19:15 <greymalkin> mojjo: I actuall have a wrapper that I use for that: http://lpaste.net/355247
19:15 eikke joined
19:15 <greymalkin> Well, not quite the same thing.
19:16 <greymalkin> mojjo, consider matching on whether the `Value` you're parsing is a (String t) vs an (Array a)
19:17 <greymalkin> You might also, instead, make the "key1":"abc" a singleton list when it's parsed, rather than Eithering it if they don't have different meanings.
19:18 <greymalkin> LordBrain: I'm really not sure what you mean -- this is a pattern I've mostly just intuited up to this point.
19:19 <greymalkin> But I'm having trouble with my Currency typeclass's function `currencyCode` which takes a proxy (since I don't necessarily have access to one of the `Money` objects at the time that I need to determine the currency code.
19:19 <greymalkin> The proxy is not working as I expected it to.
19:19 <monochrom> Show actual code?
19:20 alif_bae joined
19:20 ompaul joined
19:21 <LordBrain> greymalkin, well this may or may not apply to you, but consider whether classes should be cut down... and instead using a pattern of records of functions which act as explicit dictionaries if you will.
19:21 santosst joined
19:21 <santosst> hello
19:22 <mojjo> monochrom: I'm still stuck in getting the xs out of the Object. I'm missing a function like `toList`..
19:22 <EvanR> down with class
19:22 <LordBrain> so for example, data Currency = Currency { function1:: a -> Currency -> b; function2 :: Currency -> b -> d} etc
19:22 <greymalkin> LordBrain: https://pastebin.com/f5ptUzZX
19:22 byte[]1 joined
19:23 srbaker__ joined
19:23 ADG joined
19:23 <monochrom> "type Object = Hashmap Text Value". Have you ever seen that from the docs or from the :info command?
19:24 <cocreature> mojjo: can you show us the code you currently have?
19:24 zeroed joined
19:25 <ADG> doing "stack upgrade" (-v) since 3.5 hrs, first install, reached progress 109/185 stuck since 1 hr.. what to do? getting this at last https://hastebin.com/uhakoruver.pl
19:25 plutoniix joined
19:26 <cocreature> greymalkin: try enabling ScopedTypeVariables
19:26 <cocreature> greymalkin: the reason this doesn’t work is that without ScopedTypeVariables you can’t refer to the type variables in the instance declaration in the definitions of the individual bindings in the instance
19:27 hurkan joined
19:27 <greymalkin> mojjo: this is what EvanR meant by using the parser monad
19:27 <greymalkin> https://pastebin.com/PP0RT3NV
19:28 hurkan left
19:28 <EvanR> yes but this really isnt necessary right now
19:28 <EvanR> afaict
19:28 `^_^v joined
19:29 prkc joined
19:29 <greymalkin> cocreature: Thank you. That makes sense, and seems to be almost necessary when using Proxys
19:30 <cocreature> greymalkin: you Proxies without ScopedTypeVariables are no fun
19:30 takle joined
19:30 plutoniix joined
19:31 <cocreature> greymalkin: note that if you want to refer to the type variables in the type signature of an ordinary definition you need to explicitely use "forall". otherwise you have the same behavior as without ScopedTypeVariables
19:31 <mojjo> cocreature: ok, I'm slightly getting an idea. So it' basically the same beast like a simple `type MyString = String`. I'm just having trouble with getting Hashmap in scope...
19:31 <monochrom> 90% of questions are answered 10x faster when monochrom says "show actual code"
19:32 <EvanR> the 90 10 rule
19:32 <monochrom> Pay monochrom to say "show actual code" for you! At the new low price of 0.01 bitcoin per instance.
19:32 <cocreature> even better: show code that is sufficiently self-contained that people can load it in ghci
19:32 JeanCarloMachado joined
19:34 <mojjo> monochrom: alright.. I'll wrap my repl stuff into a file and pastebin it...
19:34 <monochrom> Yours may be in the other 10%.
19:35 <monochrom> But you need to know that Hashmap totally has toList.
19:35 plutoniix joined
19:36 joe9 joined
19:36 BernhardPosselt joined
19:37 t7 joined
19:37 <BernhardPosselt> hi i was wondering if you use something like spring that lets you switch out functions by using configuration
19:38 plutoniix joined
19:38 <BernhardPosselt> e.g. not happy with cart calculation? replace it with another function
19:38 raynold joined
19:38 <BernhardPosselt> shopping cart*
19:39 jangsutsr joined
19:40 freusque joined
19:41 SpinTensor joined
19:41 <cocreature> BernhardPosselt: there is not really a framework for that. just make your code a function that takes the things as arguments that you want to replace
19:42 <BernhardPosselt> so what if there is pre-existing code that has a default function
19:42 <BernhardPosselt> then somewhere we have a part that passes the default function, right?
19:43 <cocreature> you can’t magically replace parts of existing code
19:43 <BernhardPosselt> well in spring you can
19:43 <cocreature> I don’t think you can replace arbitrary parts of code that doesn’t use spring either, right?
19:44 <BernhardPosselt> i think you can
19:44 <cocreature> huh ok. well you still can’t do that in haskell :)
19:44 <BernhardPosselt> well i think you can do it :D
19:44 tomphp joined
19:44 <BernhardPosselt> e.g. you use a function based on some configuration in a text file
19:45 <BernhardPosselt> e.g.
19:45 <BernhardPosselt> Company.Cart.calculateCart
19:45 <BernhardPosselt> instead of
19:45 romank joined
19:45 <BernhardPosselt> Default.Cart.calculateCart
19:46 <BernhardPosselt> that is if you can dynamically pass functions by absolute package?
19:46 Yuras joined
19:48 <BernhardPosselt> so basically you want a system that is extensible
19:49 plutoniix joined
19:49 <cocreature> even if you could (which you can’t, at least not without terrible hacks), that would still require that the code that uses “calculateCart” reads the text file to figure out which implementation to call so at that point it could just take a parameter that represents the implementation of “calculateCart” that it uses
19:49 <BernhardPosselt> cocreature: correct :)
19:49 <cocreature> so I don’t really understand what you’re asking for
19:49 <BernhardPosselt> however how can i switch out default behavior
19:50 <cocreature> as I said, you can’t if the author didn’t have that in mind
19:50 <monochrom> You need two layers.
19:50 descender joined
19:50 <monochrom> Front layer (responsible for parsing config file) knows about defaults and reads config file to override defaults.
19:51 alif_bae joined
19:51 <monochrom> But regardless of whether defaults are chosen or vetoed, this front layer tells the second layer which function to use, explicitly.
19:51 <BernhardPosselt> yep, thats what i mean
19:51 <monochrom> The second layer doesn't know what "default" means. No such thing there. It just uses whichever function the front layer says.
19:52 <BernhardPosselt> however how is the front layer going to choose the correct function?
19:52 <BernhardPosselt> if its not written by you
19:52 <monochrom> Example. Front layer reads config file. If config file empty, call "map sin [1,2,3]". If config file non-empty, call "map cos [1,2,3]".
19:52 carlomagno joined
19:53 <monochrom> More accurately, it's really "map (if config file empty then sin else cos) [1,2,3]".
19:53 <BernhardPosselt> ok, but sin and cos need to be hard coded right?
19:53 <cocreature> BernhardPosselt: are you looking to change the function without recompiling and without having only a fixed set of functions available?
19:53 <monochrom> Second layer is simply \f -> map f [1,2,3]
19:53 <monochrom> Yes.
19:53 tomphp joined
19:53 <BernhardPosselt> ok, real world example
19:54 <cocreature> it sounds like you’re looking for dynamic loading of Haskell modules
19:54 <BernhardPosselt> im working with hybris which is a java based product management/shop system
19:54 Apocalisp joined
19:54 <BernhardPosselt> they have a default shop implementation with controllers and all the stuff
19:54 <monochrom> Oh, real world example is going to be "the code comes from another config file because we love security holes". I know that one. wontfix.
19:54 <BernhardPosselt> so you can start up a webshop very quickly with no code
19:54 <BernhardPosselt> but if you want to adjust things you simply change xml and overwrite "objects" by using the same keyword
19:55 <EvanR> hmm the web with no code, would be nice
19:55 takle joined
19:55 <BernhardPosselt> so a customer wants us to add additional price calculations to the cart for instance
19:55 <cocreature> BernhardPosselt: I think you might be looking for something like https://hackage.haskell.org/package/plugins or if you need a minimal example I have a blogpost https://purelyfunctional.org/posts/2016-05-20-dynamic-loading-haskell-module.html
19:55 <BernhardPosselt> sounds good :)
19:56 <monochrom> cocreature, does plugin still work today? I mean today's GHC 8
19:56 <cocreature> monochrom: afaik it does. it has been updated fairly recently
19:56 <cocreature> monochrom: you need to use some weird linker tricks that I figured out for that blogpost
19:56 sgronblo joined
19:57 chaosmasttter joined
19:57 <cocreature> BernhardPosselt: but unless you have a very strong reason not to, the usual solution in Haskell is to just make hybris a library and your config file the Main.hs file that calls that library with the implementations you want. if you want to change the implementation you just have to recompile that single file and that’s it
19:57 <cocreature> dynamic loading is rarely done in Haskell and is quite painful
19:57 Fendor joined
19:58 <BernhardPosselt> so tl;dr: if you want to build something similar in haskell you would ship a default frontend and if you want to adjust one part you have to throw that away and rebuild everything :D?
19:59 <cocreature> why would you need to throw everything? just change the parts you care about
19:59 <BernhardPosselt> right but what if the parts you care about are nested more deeply?
20:00 <BernhardPosselt> kinda sounds like you would create a record with all functions in Main.hs
20:00 flatmap13 joined
20:00 <cocreature> create a nested record? :)
20:00 <monochrom> Your hardware is flat memory and flat disc sectors. There is no depth.
20:00 <BernhardPosselt> so if i wanted to change one function id go to Main.hs and write a new function into that record?
20:00 <monochrom> If the part I want changed is on sector 001, I just change sector 001. There is no depth.
20:01 <cocreature> BernhardPosselt: if you are trying to say that it’s more painful to build that kind of system in Haskell than it is in Java you’re probably right :)
20:01 <BernhardPosselt> im interested in the functional approach/equivalent :D
20:01 <BernhardPosselt> could be painful in haskell but who knows maybe its common practice in another functional language
20:02 <monochrom> It is painful but be careful what the reason is.
20:02 <Tuplanolla> I could imagine doing that in Scheme quite easily, BernhardPosselt.
20:02 <monochrom> The reason is not an artificial definition of "depth". The reason is an after-thought hot-code-loading system.
20:02 tomphp joined
20:02 <Tuplanolla> I could also imagine it quickly becoming completely unmanageable.
20:02 nickolay joined
20:03 <monochrom> Erlang for example is sufficiently functional too but it's also designed for hot-code-loading from day 1.
20:03 takle joined
20:03 <BernhardPosselt> i mean it could also work at compile time :)
20:03 mmn80 joined
20:03 <monochrom> So the reason is not an artificial dichotomy of "language paradigms" either.
20:03 <BernhardPosselt> compile this list of files but ignore that file and use my custom file :D
20:04 <EvanR> compile time hot code loading
20:04 <BernhardPosselt> that wouldnt require hot reloading
20:04 <BernhardPosselt> oh :)
20:04 <EvanR> now ive seen it all
20:04 <Tuplanolla> If you don't need portability, you can always do it at the foreign level, BernhardPosselt.
20:04 <monochrom> No, you haven't seen edit time hot code loading.
20:05 <Fendor> hey, does anyone know how to use the ghc-llvm backend on windows?
20:05 <Tuplanolla> Just because it's possible doesn't mean it's a good idea though: https://github.com/Tuplanolla/ld-prehaskell
20:05 <monochrom> If it's just compile time, you just control it from your main.hs or something.
20:05 <cocreature> Tuplanolla: that can’t really work if GHC inlines definitions, right?
20:06 <monochrom> which is what cocreature said.
20:06 <cocreature> and GHC does that a lot
20:06 <Tuplanolla> You need to do the trick at linktime, cocreature.
20:06 mmachenry joined
20:06 augur joined
20:06 <BernhardPosselt> what would Main.hs look like? calculate_cart = custom_calculate_cart?
20:06 <Tuplanolla> That's why I said foreign.
20:06 a3Dman joined
20:07 <monochrom> Hot swapping is so passe. We need to move forward to thermonuclear swapping.
20:08 <EvanR> java clojure erlang elixir seem to think its a good idea
20:08 <cocreature> Tuplanolla: inlining happens way before linking so the code might not even reference the symbols you are replacing at link time
20:08 <Tuplanolla> I know all this, cocreature.
20:08 <monochrom> Yes BernhardPosselt, or change "import Calculator1" to "import Calculator2".
20:08 <monochrom> Or both.
20:08 <BernhardPosselt> i see :)
20:11 <BernhardPosselt> another question: some companies think its a good idea to distribute only binaries to you (who cares, everyone uses a decompiler)
20:11 <BernhardPosselt> in that case you probably cant use a Main.hs
20:11 _noblegas joined
20:11 blym_ joined
20:11 <cocreature> then you can still use the dynamic loading approach the “plugins” package takes
20:11 <EvanR> haskell decompiler, interesting
20:12 <cocreature> EvanR: I think there is one
20:12 <BernhardPosselt> at least for java it works incredibly well :D
20:12 <BernhardPosselt> everything except enums
20:12 <cocreature> EvanR: to annoy haskellers it’s written in python https://github.com/gereeter/hsdecomp
20:12 <EvanR> haha
20:13 jship joined
20:13 <EvanR> how in the world could it work
20:14 <mojjo> monochrom: alright, here's a source file which demonstrates my aeson parsing task: http://lpaste.net/355248
20:14 sfcg joined
20:14 romank joined
20:16 `^_^v joined
20:17 <monochrom> Object is Hashmap Text Value. You can use Hashmap's toList to get [(Text, Value)].
20:17 <monochrom> Value is an algebraic data type. Read the doc or use the :info command to see what are its possibilities.
20:17 romank joined
20:17 <monochrom> Use pattern matching and conditional branching and whatnot to determine whether you want to output a Left or a Right.
20:18 <Fendor> so, someone tried using llvm on windows?
20:18 <cocreature> Fendor: what problems are you running into?
20:18 stoopkid joined
20:18 <Fendor> cocreature, i installed llvm 3.7 via the installer, but when i try to stack build, ghc says, it couldnt execute 'opt'
20:20 <cocreature> Fendor: you can specify the path to opt via "-pgmlo path" iirc
20:20 <Fendor> cocreature, i'm not sure what the path might be, i have no program named opt in the installation directory
20:21 <cocreature> Fendor: that seems more of a problem with your llvm installation. llvm should definitely include opt _somewhere_. sadly I don’t have a lot of experience with llvm on windows so I don’t know where it is supposed to be
20:22 v0latil3 joined
20:22 <Fendor> cocreature, ok, thanks, then i know what i have to look for
20:22 <cocreature> Fendor: which installer did you use? I only see an installer for clang and none for llvm itself
20:23 mrkgnao joined
20:23 v0latil3 joined
20:23 <Fendor> cocreature, used the one for clang, thought this would work out. I tried to compile llvm from source
20:23 <Fendor> still couldn't find any executable with the name opt...
20:23 <cocreature> Fendor: iirc the clang installer statically links against llvm so it doesn’t help here.
20:24 <cocreature> Fendor: how exactly did you compile it?
20:24 <cocreature> and what did you compile?
20:24 freusque joined
20:25 <Fendor> i downloaded the sources, opened it in clion, previously installed cygwin with gcc, and executed `build all`
20:26 takle joined
20:26 <cocreature> I just used ninja the last time I build llvm on windows. I have no idea what exactly clion does
20:27 mfukar joined
20:27 <mojjo> monochrom: unfortunately that does not do the trick. Data.HashMap.toList is not working on Object. `Expected type: Maybe (Map k a); Actual type: Maybe Object`
20:27 <cocreature> but you should probably try talking to llvm guys about this :)
20:27 Guest___ joined
20:27 fotonzade joined
20:27 <cocreature> mojjo: are you sure you are using Data.HashMap.toList and not Data.Map.toList?
20:27 chlong joined
20:28 <Fendor> as far as i know, clion should execute cmake and then make :/
20:28 <Fendor> cocreature, is there a llvm irc as well?
20:28 <cocreature> Fendor: yes #llvm on oftc
20:29 <Fendor> cocreature, ok, will ask there afterwards, thank you!
20:29 \malex\ joined
20:29 peterbecich joined
20:30 flatmap13 joined
20:30 <mojjo> cocreature: yes: http://lpaste.net/355248
20:30 flatmap13 joined
20:31 <cocreature> mojjo: you need to use Data.HashMap.Lazy and change the import to that as well
20:32 gawen joined
20:33 <mojjo> cocreature: alright, that was it...
20:34 <mojjo> I guess it's why I'm explicity using the lazy bytestring..
20:34 <mojjo> why->because
20:34 <cocreature> it’s not about lazy bytestrings. it’s about lazy hashmaps
20:34 <pikajude> this is a confusing flowchart
20:34 <cocreature> aeson is representing Object as a lazy hashmap so you have to work with that
20:34 <mojjo> cocreature: alright..
20:35 unyu joined
20:35 <hylo> i tried to run this ST example, but it panicked: http://lpaste.net/355251 is this the same bug as https://ghc.haskell.org/trac/ghc/ticket/13106 ?
20:35 zeroed joined
20:36 insitu joined
20:40 <hylo> whoops, i didnt add imports...
20:40 takle joined
20:43 <hylo> now it works fine. interesting error though
20:47 sneakysicko joined
20:48 dfeuer joined
20:48 JeanCarloMachado joined
20:48 fotonzade joined
20:51 sgronblo joined
20:51 ExpHP joined
20:51 jetho joined
20:52 yqt joined
20:53 urdh joined
20:54 rkazak joined
20:56 oisdk joined
20:58 haskellbro joined
20:58 gaze__ joined
21:00 freeside joined
21:02 xcmw joined
21:03 vikaton joined
21:04 <c_wraith> a ghc panic is a bug, not matter how invalid the input.
21:05 <c_wraith> *no matter
21:05 zzz joined
21:05 <c_wraith> making ghc's brain explode, on the other hand, is perfectly normal for some mistakes.
21:06 StoneToad joined
21:06 bod_ joined
21:06 timtro joined
21:07 carlomagno1 joined
21:07 caryon joined
21:07 caryon left
21:07 <mojjo> cocreature: getting closer and closer with the parsing.. Atm, I'm stuck with coercing Data.Aeson.Text to String...
21:08 augur joined
21:08 LKoen joined
21:08 halogenandtoast joined
21:09 <pikajude> why are you coercing that to String?-
21:09 <pikajude> doesn't it contain a Text already
21:10 takle joined
21:10 <mojjo> pikajude: good question, I though it's better to get that out of the 'JSON world' but yeah.. maybe it's not needed
21:11 carlomagno joined
21:13 <pikajude> well what do you want to do with it
21:14 oisdk joined
21:14 matrium joined
21:14 LordBrain joined
21:15 <LordBrain> Would it be sensible to classify x86 machine code under Codec ?
21:15 augur joined
21:15 Trenif joined
21:15 <dmwit_> There's a "Language" category...
21:15 <monochrom> There is no such thing as Data.Aeson.Text
21:16 <pikajude> it's a module monochrom
21:16 <LordBrain> dmwit, langauge is the assembly tho right... not the bits
21:16 sedeki joined
21:16 bennofs1 joined
21:16 <monochrom> Ah. Still, the Text type is not an aeson internal thing.
21:16 <LordBrain> oh were you not talking to me?
21:16 <mojjo> pikajude: atm I just want to parse the json into a 'clean' haskell data structure. Performance is not important, so'll try to coerce the keys to strings.
21:16 <pikajude> oh i guess it's actually called String inside aeson
21:16 <dmwit> I can't think of a meaning for "x86 machine code" for which Codec would be a sensible classification.
21:17 <LordBrain> why not
21:17 <dmwit> Codecs are *usually* about compression, and especially audio and video.
21:18 <LordBrain> they're about encodings, take base64, has nothing to do with audio or video
21:18 <dmwit> (s/and especially/especially of/ makes that sentence a bit more sensible)
21:18 <monochrom> Codec.Aeson?
21:18 <Tuplanolla> Here's another definition: codes are those things only codec developers care about.
21:18 <Tuplanolla> What an opportune typo there.
21:18 <monochrom> Codec.Church.SystemF
21:19 aarvar joined
21:19 <LordBrain> well, i dont think its so clear cut, but i asked for opinions and you offered, so thanks
21:20 albertus1 joined
21:20 takle joined
21:20 <mojjo> ok, I see. It's Data.Text from the text pkg that is used by Aeson
21:20 <dmwit> I don't know what you're doing. But with the little data you've given, I would strongly suggest Language.
21:20 <LordBrain> i've seen encryption stuff being put in codec
21:21 <athan> biTraverse :: (a -> m c) -> (b -> m d) -> f a b -> m (f c d) -- is this a thingy?
21:21 Levex joined
21:21 <monochrom> Does your package decode x86 machine code to Prolog?
21:21 <MarcelineVQ> athan: https://hackage.haskell.org/package/bifunctors-5.4.2/docs/Data-Bitraversable.html#v:bitraverse
21:21 <LordBrain> no
21:22 <LordBrain> it doenst even fully dissassemble it
21:22 carlomagno joined
21:22 <LordBrain> it just tells you things like, X is a valid instruction
21:22 <monochrom> This sounds like a developer's tool.
21:22 <LordBrain> yeah
21:23 halogenandtoast joined
21:23 <LordBrain> it nearly is a complete disassembler, but not quite
21:23 <athan> MarcelineVQ: Thank you ._.
21:23 <monochrom> It does seem that Language.* is collecting developer's tools.
21:23 <MarcelineVQ> athan: it should be in base in the not too distant future as well so you can feel confident writing code using it
21:24 <dmwit> LordBrain: Given that there's an "Encryption" category, I find that odd.
21:24 <dmwit> LordBrain: There's also "Testing", "Compliers/Interpreters", and "Development".
21:24 <dmwit> Whoops, Compilers, not Compliers, of course. =)
21:25 <Tuplanolla> Tag-based module system when?
21:25 <monochrom> YES!
21:25 darjeeling_ joined
21:25 hackebeilchen joined
21:26 <MarcelineVQ> hackagebooru
21:26 <LordBrain> alright
21:27 <LordBrain> well i'm just going to leave it as it is presently, which is none of the above
21:27 <LordBrain> heh
21:27 <monochrom> It's a bit unfortunate that it is not too easy to ask hackage for a complete list of packages (under a given prefix).
21:27 <dmwit> Come to think of it, "Testing" doesn't seem like a very good suggestion. Scratch that one.
21:27 <dmwit> monochrom: https://hackage.haskell.org/packages/ ?
21:27 Gurkenglas joined
21:27 <dmwit> Click a category to get all the packages in that category...
21:28 nomicflux joined
21:28 <dmwit> (Or: what do you mean by "prefix"?)
21:28 <MarcelineVQ> monochrom: it's not too hard either though, but you end up asking through Cabal, or I have anyway
21:28 <monochrom> Because what you should do is the social norm thing rather than the conceptual-linguistic analysis thing. I.e., you should just find the prefix that already contains the most packages most similar to yours, and not care about what the words mean.
21:29 justin2 joined
21:29 ebisaleth joined
21:30 <monochrom> I guess I mean category
21:30 polll joined
21:30 <Tuplanolla> If I was the first person to write quantum computing packages, I'd put them under `Ponies`.
21:31 Klumben joined
21:32 kadoban joined
21:32 <monochrom> You can still choose from Control, Quantum, and Scientific :)
21:32 <pikajude> Control.Ponies
21:33 carlomagno1 joined
21:33 <monochrom> Oh neat numeric-quest has all the linear algebra computations I want.
21:33 <LordBrain> lol
21:34 <LordBrain> i'm going to put it there pikajude, thanks for the suggestion
21:34 <monochrom> onoes
21:36 alem0lars joined
21:36 unyu joined
21:36 flatmap13 joined
21:38 mulk joined
21:39 <Gurkenglas> Do we have a benchmark file that generates lens errors that ought to look better?
21:39 SolarAquarion joined
21:42 xacktm joined
21:43 cschneid_ joined
21:43 oisdk joined
21:44 sillyotter joined
21:44 roar joined
21:45 sgronblo joined
21:45 roar joined
21:45 ebisaleth left
21:46 jophish joined
21:46 taira joined
21:47 <EvanR> you have functor, applicative, monad
21:48 shayan__ joined
21:48 <EvanR> where does contrafunctor lead?
21:48 <EvanR> contraapplicative?
21:48 <c_wraith> I'm pretty sure there's something that covers that.
21:49 <c_wraith> https://hackage.haskell.org/package/contravariant-1.4/docs/Data-Functor-Contravariant-Divisible.html
21:49 <monochrom> contrafunctor leads to fear, fear leads to anger, anger leads to using Haskell in anger.
21:49 WhiskyRyan joined
21:50 <monochrom> Eh! Divisible. That sounds interesting.
21:50 <monochrom> I think I saw an edwardk video on that.
21:50 plutoniix joined
21:50 <c_wraith> yeah, I know he's done at least one.
21:51 <c_wraith> and it is one of his libraries
21:51 grumble joined
21:51 <EvanR> so uh
21:51 <EvanR> do you get a free Divisible with a Contrafunctor?
21:52 joelburget joined
21:52 <c_wraith> no.
21:53 carlomagno joined
21:53 <c_wraith> unless you mean category-theoretical free, in which case.. Maybe.
21:53 hiratara joined
21:53 plutoniix joined
21:54 <EvanR> conquer :: f a
21:54 <EvanR> uhm...
21:55 iqubic joined
21:55 <EvanR> not sure how something implements that
21:55 <iqubic> How does this type signature look: firstMatch :: [(a -> Bool, b)] -> a -> Maybe b
21:55 <EvanR> ok it could ignore the given a, in the case of a -> b
21:56 <Gurkenglas> The compiler unpacks type aliases if that lets it pull constraints contained in the aliases to the front of a type. Can that be disabled?
21:56 <iqubic> It's supposed to return the b of the first a that passes.
21:56 <monochrom> If you can find that lecture video, there are concrete examples and how the generalization emerges.
21:56 <monochrom> Actually let me see if I can recall it.
21:56 <iqubic> Or nothing if all the test fail.
21:57 <c_wraith> EvanR, Predicate is one of the provided instances. newtype Predicate a = Predicate (a -> Bool)
21:57 <iqubic> Predicate is a thing
21:57 <iqubic> ??
21:57 <iqubic> That will help me in my task
21:58 <c_wraith> EvanR, so.. Yeah, const True and const False both fit that type.
21:58 meoblast001 joined
21:58 <iqubic> c_wraith: How does Predicate work?
21:58 <EvanR> oh right Predicate
21:59 <c_wraith> iqubic, it's a thing in the contravariant package. if you want to import that package, it's there..
21:59 <iqubic> @index Predicate
21:59 <lambdabot> bzzt
21:59 <c_wraith> https://hackage.haskell.org/package/contravariant-1.4/docs/Data-Functor-Contravariant.html#t:Predicate
21:59 <iqubic> Why is that a thing?
21:59 <iqubic> Why not just use a -> Bool?
22:00 <c_wraith> probably more for pedagogical reasons than practical.
22:00 <iqubic> How does this type signature look: firstMatch :: [(a -> Bool, b)] -> a -> Maybe b
22:00 <iqubic> It's supposed to return the b of the first a that passes.
22:00 strykerkkd joined
22:00 <iqubic> Or nothing if all the test fail.
22:00 <iqubic> I'm not sure how to write that though.
22:00 takle joined
22:00 a3Dman joined
22:01 <c_wraith> the type certainly is coherent.
22:01 <iqubic> What does that mean?
22:01 yanosh joined
22:01 <c_wraith> it can be implemented in a way that has meaning.
22:01 <sedeki> how can I learn the algebra that most Haskellers seem to know
22:01 <sedeki> or, where can I learn it?
22:02 yanosh left
22:02 hybrid joined
22:02 plutoniix joined
22:02 <c_wraith> sedeki, I learned most of what I know by just watching people chat here. :)
22:02 <iqubic> c_wraith: I don't know how to write that function.
22:02 <Tuplanolla> @djinn (a -> bool, b) -> (a -> (bool, b)) -- You could first define this, iqubic.
22:02 <lambdabot> Cannot parse command
22:02 <Tuplanolla> @djinn (a -> bool, b) -> (a -> (bool, b))
22:02 <lambdabot> f (a, b) c = (a c, b)
22:02 byron1 joined
22:03 <sedeki> c_wraith really?
22:03 flatmap13 joined
22:03 <Tuplanolla> Map that, apply each one to your argument and find the first match, iqubic.
22:03 <c_wraith> iqubic, just start writing it. write out the pattern matching structure, then see what you have to work with.
22:03 <iqubic> Tuplanolla: Is that the way to do it?
22:03 <Tuplanolla> That's one easy way, iqubic.
22:03 meoblast001 joined
22:03 <byron1> part
22:03 byron1 left
22:03 <ski> join
22:04 <c_wraith> sedeki, yep. eventually I started watching a few videos that came up on reddit, but I still think half of them are incomprehensible. :)
22:05 <iqubic> How do I write this: (a -> bool, b) -> (a -> (bool, b))
22:05 <Tuplanolla> I just showed you, iqubic.
22:05 <iqubic> Oh.
22:05 <iqubic> So how does that help me solve firstMatch?
22:05 <sedeki> c_wraith what books have you read about haskell?
22:06 <sedeki> c_wraith are you pursuing haskell on a hobbyist level or working with it?
22:06 <c_wraith> in their entirety? none. and most books I read about it, I read to evaluate how much they get wrong. :)
22:06 <c_wraith> I picked up haskell entirely on the job.
22:07 <Tuplanolla> @let djinn_f (a, b) c = (a c, b)
22:07 <lambdabot> Defined.
22:08 <c_wraith> not my current job, mind you.
22:08 <Tuplanolla> :t \ fs x -> find fst (fmap ($ x) (fmap djinn_f fs))
22:08 <lambdabot> (Functor t, Foldable t) => t (a -> Bool, b) -> a -> Maybe (Bool, b)
22:08 <Tuplanolla> Like so, iqubic.
22:09 <sedeki> c_wraith very cool
22:09 roar joined
22:09 <iqubic> I don't want the end result to to be Maybe (Bool, b), but just b
22:09 <iqubic> or rather Maybe b
22:09 <Tuplanolla> :t \ fs x -> fmap snd (find fst (fmap ($ x) (fmap djinn_f fs)))
22:09 <lambdabot> (Functor t, Foldable t) => t (a -> Bool, b) -> a -> Maybe b
22:10 oisdk joined
22:10 <Tuplanolla> I'm sure better ways exist too.
22:10 mmachenry joined
22:10 <c_wraith> iqubic, I really think the best way for you to learn is to just write the pattern matches out by hand and work with what they give you.
22:10 <sedeki> c_wraith I've read like 2 books on haskell already, and half-way through a 3rd. still don't get certain things.
22:11 <iqubic> c_wraith: How would you write the pattern matches for this?
22:11 <sedeki> but I think it will make sense if I just start making some projects
22:11 <c_wraith> sedeki, haskell is a constant learning experience, if you want to keep up with what people are doing. there are always more things to learn.
22:12 plutoniix joined
22:13 <c_wraith> iqubic, I find starting out with the simplest possible thing is a good strategy. then add bits of additional elaboration when you see that you can.
22:14 crobbins joined
22:15 <c_wraith> iqubic, you have a function that takes two arguments, so write out a function definition that takes two arguments. you can leave the body undefined to start.
22:15 swhalen joined
22:16 dm3 joined
22:17 joe9 joined
22:17 <c_wraith> iqubic, then you can start refining. the first argument is a list. you know you can match whether that list is empty or not, so split the definition in two for each case. see if you have enough information to implement the body in either case. proceed with refinements like that.
22:18 <c_wraith> err, split the definition in two *to handle* each case.
22:18 <iqubic> c_wraith: I have something that almost works, but not quite.
22:18 <c_wraith> iqubic, so put it on lpaste.net
22:18 <joe9> I am building a table data structure, where I traverse sequentially and add the (row,column) cell. Are there any library packages that can help? I found tabular. Just want to check if there is something better out there.
22:20 <lpaste> iqubic pasted “Almost works” at http://lpaste.net/355252
22:20 eschnett joined
22:20 <iqubic> So, the first part is the solution I can up with. The second part is the error I get when trying to compile my thing.
22:21 <joe9> I also found this https://hackage.haskell.org/package/table-layout
22:21 <ReinH> iqubic: don't wrap the : constructor in []
22:21 gFL0SIEeAVW1 joined
22:22 blym_ joined
22:22 Luke joined
22:22 <iqubic> Why not?
22:22 <ReinH> Because it is just :
22:22 <iqubic> Oh. I see.
22:22 <glguy> The pattern [_] is equivalent to (_ : []), it matches a single-element list
22:23 <ReinH> (x:xs) is a list. [x:xs] is a list of lists.
22:23 <iqubic> Ah.
22:23 MP2E joined
22:24 haskelln00b joined
22:24 <ReinH> [x:xs] matches a list containing one element: a non-empty let.
22:24 haskelln00b left
22:24 <c_wraith> iqubic, that's a pretty common mixup. other than that, everything looks right.
22:25 <lpaste> iqubic pasted “Second Try” at http://lpaste.net/355253
22:25 <iqubic> Thanks for being real helpful error message.
22:25 <ReinH> You still need to wrap : with ()
22:25 <iqubic> Oh.
22:25 <c_wraith> that is, (x:xs) is the common match pattern.
22:26 <iqubic> Now it works
22:26 <ReinH> (x:xs) is a pattern, x:xs is a parse error, [x:xs] is a pattern, but the wrong one.
22:26 albertus1 joined
22:27 refold joined
22:27 <iqubic> https://www.willamette.edu/~fruehr/haskell/evolution.html
22:27 <iqubic> How does the Junior Solution work.
22:27 <c_wraith> well.. There's a bit more subtlety to it than that, but it's basically true when defining functions.
22:27 bjz joined
22:27 <iqubic> You can pattern match on (n+1)?
22:28 <c_wraith> iqubic, oh, that was removed from haskell 2010
22:28 oisdk joined
22:28 <c_wraith> that page is *old* and not updated
22:28 darjeeling_ joined
22:29 <monochrom> The problem with learning from the Internet.
22:29 alif_bae joined
22:29 oisdk joined
22:31 argent0 joined
22:33 <iqubic> Did people know that lambda bot can do this:
22:33 <iqubic> @unmtl StateT s IO a
22:33 <lambdabot> s -> IO (a, s)
22:33 <iqubic> That's so cool.
22:33 <monochrom> No.
22:33 srbaker joined
22:33 <iqubic> It unwraps a monad transformer.
22:34 hiratara joined
22:34 <ReinH> Have we taught it about ExceptT yet?
22:34 <iqubic> > ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
22:34 <lambdabot> <hint>:1:1: error: parse error on input ‘++++++++++’
22:35 <iqubic> Darn it.
22:35 <c_wraith> the > prefix only kicks off haskell evaluation. BF evaluation is a different command.
22:35 <monochrom> Did people know that lambdabot doesn't know Morse code?
22:35 erikd joined
22:36 <iqubic> c_wraith: DO you know the BF evaluation command?
22:36 <monochrom> No.
22:36 safe joined
22:36 <ski> @help bf
22:36 <lambdabot> bf <expr>. Evaluate a brainf*ck expression
22:37 <c_wraith> i wasn't even sure it didn't get removed in the last winnowing
22:37 <iqubic> @bf ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
22:37 <lambdabot> Hello World!
22:37 <iqubic> Cool
22:37 <iqubic> @fact
22:37 <lambdabot> Maybe you meant: part faq
22:38 <iqubic> @dice 1 1
22:38 <lambdabot> unexpected '1': expecting operator or end of input
22:38 <iqubic> @dice 1
22:38 <lambdabot> unexpected end of input: expecting operator or end of input: no rolls in expression
22:38 <iqubic> @dice
22:38 <lambdabot> unexpected end of input: expecting number, "d" or "("
22:38 <iqubic> @dice 2d2
22:38 <lambdabot> iqubic: 1+2 => 3
22:38 <Tuplanolla> Maybe you want your own little lambdabot, iqubic.
22:38 <iqubic> I really do.
22:39 <iqubic> Can I get that as stack program?
22:39 <glguy> You can spam lambdabot in /msg
22:39 takle joined
22:39 sgronblo joined
22:39 <iqubic> I want it as an offline thing.
22:39 <Tuplanolla> That can be arranged.
22:39 <glguy> It's on hackage
22:40 <sedeki> hehe.
22:40 <Gurkenglas> "stack install lambdabot", I think
22:41 <iqubic> But it needs a ton of dependecies
22:42 <iqubic> And those don't want to install themselves.
22:44 beanbagu1 joined
22:49 {emptyset} joined
22:49 filterfish joined
22:50 fosterite joined
22:50 xcmw joined
22:51 oisdk joined
22:51 aarvar joined
22:52 m0d joined
22:53 <monochrom> Perhaps you should offer to pay for someone to do it for you.
22:55 Welkin joined
22:55 Durbley joined
22:56 pie_ joined
22:56 Durbley joined
22:58 peterbecich joined
22:59 takle joined
23:00 <iqubic> Can't I do it myself?
23:02 nakal_ joined
23:02 <suzu> lmao
23:03 zzz joined
23:03 uglyfigurine joined
23:03 xcmw joined
23:03 pita joined
23:04 meba joined
23:05 CrazedProgrammer joined
23:05 zennist joined
23:06 torstein_ joined
23:06 NeverDie joined
23:12 butterthebuddha joined
23:14 <dmwit> ReinH: https://github.com/lambdabot/lambdabot/blob/master/lambdabot-haskell-plugins/src/Lambdabot/Plugin/Haskell/UnMtl.hs#L135-L157
23:15 <dmwit> Should be pretty mechanical to add ExceptT. You should totally do it!
23:15 noexcept1 joined
23:15 soniku joined
23:15 <noexcept1> I don't understand the difference between let and where. Why do we need two different syntaxes for replacing something within a scope?
23:15 takle joined
23:17 sfcg joined
23:17 <ReinH> @google haskell let vs where
23:17 <lambdabot> https://wiki.haskell.org/Let_vs._Where
23:17 freusque joined
23:17 <ReinH> The second result is also good: http://stackoverflow.com/questions/4362328/haskell-where-vs-let
23:18 <c_wraith> noexcept1, they are in different parts of the syntax. let...in is an expression. where clauses can only attach to a couple of places.
23:19 wizwizwizwiz joined
23:19 lambda-11235 joined
23:19 <ReinH> For the same reason that mathematicians do, I suppose.
23:20 <wizwizwizwiz> so can i use haskell to make something imitating a "database" with "queries" and all of that... and ideally in a manner superior to existing SQL databases
23:21 lavalike_ joined
23:21 <dmwit> I assign high probability to the answer "no". Given how vague your question is, it suggests you know little about just how much work has gone into existing SQL databases, and therefore *you* are unlikely to do better.
23:21 <c_wraith> as soon as you define what "better than SQL" means, you can certainly do it in Haskell.
23:23 <c_wraith> you can usually find a way to do something faster than a traditional RDBMS does, but at the expense of basically everything else they provide. usually all the ACID properties get lost.
23:23 halogenandtoast joined
23:24 pie_ joined
23:24 <dmwit> Ugh, that was incredibly rude. I'm sorry. Something about your question rubbed me the wrong way, and I responded badly.
23:25 <jao> yes!
23:25 <jao> (sorry, wrong emacs buffer)
23:26 lavalike joined
23:27 afarmer joined
23:27 <noexcept1> How would I go about understanding Haskell's evaluation strategy?
23:27 sellout- joined
23:27 <Welkin> noexcept1: read docs for ghc
23:27 <ReinH> @where lazy
23:27 <lambdabot> http://www.vex.net/~trebla/haskell/lazy.xhtml
23:28 <ReinH> noexcept1: that one is good too
23:28 <noexcept1> I understand that not everything is evaluated right away, rather only as needed, but that's very hand-wavy.
23:28 <ReinH> Or read Introduction to Functional Programmming Using Haskell by Richard Bird if you can find a copy
23:28 tromp joined
23:28 <ReinH> or read the Haskell report
23:29 jetho joined
23:29 <Cale> noexcept1: The basic idea of lazy evaluation (which isn't *quite* what GHC does, but is generally close enough)
23:29 <ReinH> If you want even more, read the GHC commentary on the runtime system
23:29 <Cale> is that expressions are evaluated outermost-first
23:30 kav joined
23:30 <Cale> but any work done to evaluate an expression to which a variable has been bound will remain completed so long as that variable remains in scope (and is shared between the occurrences of it)
23:31 <Cale> I'll do my usual example: suppose we have a function double x = x + x, and we wish to evaluate double (double 5)
23:31 ChaiTRex joined
23:32 <Cale> Under innermost-first evaluation, this would proceed as:
23:32 <Cale> double (double 5)
23:32 <Cale> -> double (5 + 5)
23:32 <Cale> -> double 10
23:33 <Cale> -> 10 + 10
23:33 <Cale> -> 20
23:33 sgronblo joined
23:33 <rotaerk> hmm I've decided I don't like LaTeX-style literate haskell; the tags and stuff make it harder to read than simply using plain text and bird-style code quoting
23:33 <Cale> With plain outermost-first evaluation, it would be:
23:33 <Cale> double (double 5)
23:33 <rotaerk> the LaTeX style would be useful if you were writing a compilable code-containing article though
23:33 <Cale> -> (double 5) + (double 5)
23:33 <Cale> -> (5 + 5) + (double 5)
23:34 <Cale> -> 10 + (double 5)
23:34 <Cale> -> 10 + (5 + 5)
23:34 <Cale> -> 10 + 10
23:34 <Cale> -> 20
23:34 <Cale> and here we see that double 5 gets evaluated twice because it was duplicated when the x in the body of double occurred twice
23:34 <Cale> So lazy evaluation avoids that by sharing the work:
23:34 <Cale> double (double 5)
23:35 <noexcept1> how does it know that (+) requires its operands to be evaluated while double does not?
23:35 <Cale> Ah, I'm glossing over that. Really it's that (+) would pattern match on its arguments
23:35 <Welkin> Gloss
23:35 <ReinH> what gets evaluated is determined by the pattern matching in the definitions
23:35 <Cale> Evaluation ultimately gets driven forward by pattern matching
23:36 NeverDie joined
23:37 <noexcept1> why do the parameters of + not bind to the unevaluated (double 5)?
23:37 <ReinH> I'm not quite sure what "(+) requires its operands to be evaluated while double does not" means but it doesn't sound correct.
23:37 <Cale> noexcept1: They do, it's just I didn't want to unfold the definition of (+)
23:38 <noexcept1> so that pattern matching is not what forces the evaluation yet?
23:38 <Cale> Also, it's really the outermost (+) which gets evaluated, and since it immediately pattern matches on both its arguments...
23:38 fotonzade joined
23:39 <Cale> you end up needing to evaluate each of them to proceed
23:39 <noexcept1> hm, I don't see why it couldn't just leave the whole thing unevaluated
23:40 <Cale> and do what?
23:40 <ReinH> let's say we're printing the result
23:40 <ReinH> if nothing scrutinizes the result, you're right that it won't need to be evaluated
23:41 zzz joined
23:41 <Cale> Yeah the only reason that we would be evaluating this expression in the first place is to be able to match it against a pattern, perhaps in the definition of 'show', for example.
23:41 <ReinH> print (const 5 (double (double 5))) won't evaluate double
23:41 <dmwit> > error "this blows up"
23:41 <lambdabot> *Exception: this blows up
23:41 <dmwit> > const 5 (error "this doesn't blow up")
23:41 <ReinH> because const doesn't scrutinize it
23:41 <lambdabot> 5
23:41 <ReinH> @src const
23:41 <lambdabot> const x _ = x
23:41 mjora7 joined
23:42 <noexcept1> but what kind of pattern can only bind to a fully-evaluated integer?
23:42 <ReinH> We can use nats if you prefer
23:42 <Cale> Well, integers are again a weird example, because you don't usually think of their internal implementation.
23:42 <noexcept1> if I write `double :: Int -> Int` shouldn't the x in `double x = x + x` also force evaluation because it's doing "pattern-matching"?
23:42 <Cale> (if we want to continue digging that deeply)
23:43 <Cale> Ah, no, because we're not matching against a constructor there
23:43 <monochrom> No, not all patterns trigger evaluation.
23:43 <monochrom> > case undefined of x -> "thanks"
23:43 <lambdabot> "thanks"
23:43 <monochrom> Uneventful.
23:44 <ReinH> > case undefined of (x : xs) -> "oh no"
23:44 chlong joined
23:44 <lambdabot> "*Exception: Prelude.undefined
23:44 cschneid_ joined
23:44 <Cale> Also, just because it fits here, pattern matching against a newtype's data constructor similarly doesn't cause evaluation to occur
23:44 <noexcept1> so Int is a constructor and show will pattern-match it? like `show (Int x) = ..."
23:44 <ReinH> Int is a type.
23:45 <Cale> There is an internal data constructor for Int, I believe it's called I#
23:45 <Cale> You don't typically interact with that directly, but it's there.
23:45 lambdaman joined
23:45 <monochrom> Built-in numbers (and Char) are really bad examples. They receive special treatment.
23:45 <ReinH> noexcept1: you can imagine that we are working with natural numbers data Nat = Z | Suc Nat instead of integers here
23:46 <ReinH> and imagine what (+) would do, how it would pattern match on its arguments.
23:46 <Cale> Or we could just define integers like:
23:46 <Cale> data Integer = Neg Nat | Zero | Pos Nat
23:46 <ReinH> three zeros for three times the fun
23:46 <Cale> Where Pos n represents n+1, and Neg n represents -n-1
23:46 <ReinH> (I know, I know)
23:47 mr_sm1th joined
23:47 <ReinH> See, this is why Cale wanted to hand wave the integer pattern matching...
23:47 <monochrom> No, you want: (I know, I know, I know). :)
23:47 <ReinH> monochrom: :p
23:47 <Cale> If we want to be somewhat more practical, perhaps a binary representation would be better...
23:48 <Cale> But it doesn't really matter exactly how Integer is defined.
23:48 watabou joined
23:48 <noexcept1> ReinH: ah okay, well if it receives special treatment that explains why I don't understand how the rules could work there.
23:48 <ReinH> data Int = Int Bool Nat -- don't @ me
23:48 <Cale> It only receives a little bit of special treatment in practice.
23:48 theDon_ joined
23:49 <Cale> There's a data type with a data constructor still, and then the special bit is that the only field of that data constructor is an unboxed machine int
23:49 <Cale> data Int = I# Int#
23:49 featherlessbiped joined
23:50 erisco joined
23:50 <noexcept1> So is there a function in the prelude somewhere that pattern-matches this I# constructor? `show #I x = stringFromInt x`
23:51 mojjo joined
23:51 <Cale> Yeah, the Num and Show instances and such will actually match on I# and use primitive operations on the unboxed representation.
23:51 markus1199 joined
23:51 <erisco> how did Data.Tree end up with unfoldForest :: (b -> (a, [b])) -> [b] -> Forest a rather than unfoldForest :: (b -> [(a, [b])]) -> b -> Forest a ?
23:51 markus1209 joined
23:51 <Gurkenglas> I've cloned lens and tweaked a bit. What stack command will let me use ghci on this not-a-stack-project?
23:52 <Cale> https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base-
23:52 <erisco> sorry I mean unfoldForest :: (b -> [(a, b)]) -> b -> Forest a
23:52 uglyfigurine joined
23:53 <noexcept1> Cale, ReinH: Awesome, thanks. That helped me a lot with understanding. :)
23:53 SCHAPiE joined
23:53 <ReinH> noexcept1: also read this
23:53 <ReinH> @where lazy
23:53 <lambdabot> http://www.vex.net/~trebla/haskell/lazy.xhtml
23:53 <ReinH> it's monochrom's and it's very good
23:53 joseCova joined
23:54 <Cale> noexcept1: Anyway, I didn't actually show the lazy evaluation of our example -- if you'll permit the use of let to indicate the sharing, that would look something like:
23:54 <Cale> double (double 5)
23:54 <Cale> -> let x = double 5 in x + x
23:54 <erisco> nothing else that is an unfold looks like what is in Data.Tree
23:54 <Cale> -- note that we still unfolded the outermost one here
23:54 <Cale> -> let x = 5 + 5 in x + x
23:54 <Cale> -> let x = 10 in x + x
23:54 <Cale> -> 10 + 10
23:54 <Cale> -> 20
23:54 jsgrant_om joined
23:55 <Cale> and so we save performing the evaluation of double 5 twice in that way
23:55 <mojjo> is there a safe version of System.Directory.createDirectory, that returns e.g an Bool indicating success/failure of the op instead of throwing an exception?
23:55 <erisco> otherwise I've found that Forest is an edge labeled tree
23:55 <Cale> Under innermost-first evaluation, each argument to a function is evaluated exactly once.
23:55 <Cale> Under outermost-first evaluation, each argument to a function is evaluated zero or more times.
23:56 <Cale> Under lazy evaluation, each argument to a function is evaluated zero or one times.
23:57 <erisco> assuming totality
23:57 <ReinH> mojjo: wrap it in try?
23:57 Qommand0r joined
23:57 <ReinH> there generally aren't safe versions of everything that can throw an exception because try exists
23:57 infinity0_ joined
23:57 falafel joined
23:57 infinity0_ joined
23:58 mjora7 joined
23:58 dan_f joined