<    April 2017    >
Su Mo Tu We Th Fr Sa  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
00:01 <miaumiau> can anyone please help me form a MonadReader instance?
00:01 <miaumiau> I cannot for my life find a simple example anywhere on the internet
00:01 wroathe joined
00:02 <miaumiau> I want an instance that takes a type Int as environment and returns a Maybe String
00:03 armyriad joined
00:07 splanch joined
00:07 hexfive joined
00:07 <Cale> miaumiau: I'm not sure I understand
00:08 <Cale> miaumiau: That doesn't sound like a description of a MonadReader instance
00:08 <Cale> miaumiau: Do you just mean you want to write a Reader action?
00:08 takle joined
00:09 gawen joined
00:09 gibbers joined
00:12 <sophiag> Cale: i'm still struggling with this eval function :(
00:12 bjz joined
00:13 t0by joined
00:13 <sophiag> i decided to take a different approach i think will work, but now i have a whole new set of type errors...
00:13 <Cale> sophiag: hmm
00:13 <sophiag> want to take a look? eh? eh?
00:13 jimmyrcom joined
00:14 <Cale> sure
00:14 augur joined
00:15 <sophiag> i decided instead of using a list comprehension i'd take the permutations of each list and then put them back inside the records. then i could use when to recursively map over them and filter by the lambdas in the other records when the strings match, then return only what remains in the lists
00:15 takle joined
00:15 <sophiag> it's only confusing looking because of all the data constructors... http://lpaste.net/354622
00:17 <Cale> Well, the top type error there is just the way that things are associating
00:17 <Cale> Well, hmm
00:17 <Cale> Amb isn't a monad
00:17 <sophiag> no, it's just a record
00:17 <Cale> So "when" doesn't exactly make sense
00:17 <Cale> :t when
00:17 <lambdabot> Applicative f => Bool -> f () -> f ()
00:18 <sophiag> oh, i was looking for a one-armed if
00:18 <Cale> Ah, right, it's been generalised a bit, but still
00:18 <sophiag> when seems like that, but only for applicatives
00:18 <Cale> when b x = if b then x else pure ()
00:18 dan_f joined
00:18 blender joined
00:18 <sophiag> in this case should i just use if and return unit?
00:19 <sophiag> on the else i mean?
00:19 <Cale> Well, your type signature says you're meant to be producing an Amb
00:19 Avogadro joined
00:19 <Cale> So if your type signature is right, then you need to pick an Amb to produce.
00:19 <sophiag> oh, wait. that's wrong
00:19 morphit joined
00:19 <sophiag> it should be [Amb]
00:19 <Cale> ah, so maybe you'd like to produce an empty list in the other case?
00:20 <sophiag> no, i'd like to keep the Amb as is
00:20 <sophiag> i.e. not filter it
00:20 <Cale> ahh
00:20 <Cale> So you want to actually filter the list
00:20 <sophiag> basically list comprehensions were becoming intractable so i went this way so i could just recurse down one of the lists of record (the Requires)
00:21 iqubic joined
00:21 <iqubic> Alright folks. I have a question. What the heck is a Prism???
00:21 <Cale> Or indeed, use a list comprehension with some condition
00:21 <iqubic> Anyone care to help me understand prisms?
00:21 <Cale> iqubic: It's a little like a lens, but with the ability to fail to match
00:21 <sophiag> hmm
00:21 <iqubic> What does that mean Cale??
00:21 <sophiag> i'm interested in this as well
00:22 <Cale> iqubic: So it's like a traversal which traverses 0 or 1 values
00:22 <iqubic> Oh. Like maybe is only 0 or 1 values
00:23 <sophiag> you'd use a prism instead of a lens when you have a Maybe type in nested records?
00:23 <sophiag> or when?
00:23 <sophiag> err actually that doesn't make sense
00:24 nbro joined
00:24 <Cale> sophiag: Well, that might make sense -- if the thing you're going to be focusing on might or might not exist in any given piece of data.
00:24 <sophiag> yeah i was trying to think when that would actually be the case tho
00:24 <sophiag> with Maybe you've designed it that way and could just get a Nothing with a lens
00:25 <Cale> Well, you could have a lens that extracts the Maybe field
00:25 <sophiag> right
00:25 <Cale> Or you could have a prism which extracts the contents of that Maybe
00:25 <Cale> :t _Just
00:25 <lambdabot> (Applicative f, Choice p) => p a (f b) -> p (Maybe a) (f (Maybe b))
00:25 <Cale> heh
00:26 <sophiag> oh i see. yeah of course most of the time you wouldn't want to return Nothing
00:26 <Cale> such abstractions
00:26 <sophiag> vat?
00:26 <Sornaensis> @info Choice
00:26 <lambdabot> Choice
00:26 <Cale> You can choose to read p there as (->)
00:26 <Gurkenglas> We need a version of :t that doesn't automatically inline type synonyms in positive position
00:27 <Gurkenglas> ...that contain a forall. I'm guessing that's the criterion.
00:27 <Cale> So that'd become (a -> f b) -> (Maybe a -> f (Maybe b))
00:27 <sophiag> ah that's much more legible
00:27 <Sornaensis> @src Choice
00:27 <lambdabot> Source not found. It can only be attributed to human error.
00:28 <Cale> > _Just (\x -> Identity (10*x)) (Just 5)
00:28 <lambdabot> Identity (Just 50)
00:28 <Cale> Sornaensis: https://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Prism.html#t:Choice
00:29 takle joined
00:29 <iqubic> So what does a prism do??
00:29 takle joined
00:29 <iqubic> Is _head a prism?
00:29 <iqubic> Because what if you give it to an empty list.
00:30 <Gurkenglas> iqubic, if I understand it right a Prism' s a is a witness that the type s is a disjoint union of a and something else, as a Lens' s a is a witness that the type s is a product of a and something else
00:30 <Cale> right, that'd make a good example
00:30 kylepotts joined
00:30 <iqubic> Cale, did I come up with a good example??
00:31 <iqubic> How does prism work?
00:31 <sophiag> Gurkenglas: that's a very good explanation
00:31 <iqubic> It's a 0 or 1 element traversal?
00:31 <iqubic> Is that all?
00:31 indi_ joined
00:31 <iqubic> What is a disjoint union and a product??
00:32 <Gurkenglas> Umm, rephrasing: If I understand it right a Prism' s a is a witness that s looks like Either a b for some b, as a Lens' s a is a witness that s looks like (a, b) for some b
00:33 <iqubic> I see.
00:33 <iqubic> Either a b is an ADT.
00:33 <iqubic> And (a, b) is a single constructor data type.
00:34 <Gurkenglas> So prisms let you say something about types being subtypes of others
00:34 <iqubic> How so?
00:35 <Gurkenglas> a in that sense would be a "subtype" of Either a b because you can turn each a into an Either a b, and every Either a b might be an a
00:35 <iqubic> With either, you have two options for what the type can be. With (,) you only have single option.
00:35 <iqubic> Gurkenglas: That's right.
00:35 <iqubic> It gives you the functions (a -> Either a b, Either a b -> Maybe a)
00:36 <sophiag> Cale: i updated that paste if you're still looking http://lpaste.net/354622
00:36 <Gurkenglas> And like a lens can be described as a getter-setter pair, a prism can be described as a pair of that type you just wrote
00:36 codesoup joined
00:36 bollu joined
00:36 <Gurkenglas> (And the "prism laws" would be that going from the smaller type into the larger and back lands you where you started and that kinda stuff)
00:37 <iqubic> Every Square is a Rectangle, but not every Rectangle is a Square.
00:37 <iqubic> And whether you give me 'Square 5 or Rectangle 5 5' it's the same shape.
00:37 <Gurkenglas> So you could write a Prism [a] (a,a,a), to say that the three-element lists are a subtype of all lists
00:38 <Gurkenglas> *Prism'
00:38 <iqubic> However if you give me 'Rectangle 10 5' I can't turn that into a square.
00:39 <iqubic> So you get Prism' Square Rectangle
00:39 <sophiag> down to three error :p http://lpaste.net/354622
00:39 <Gurkenglas> No, Prism Rectangle Square, because the Squares would be a subtype of the Rectangles
00:39 <Gurkenglas> *'
00:39 <iqubic> I see.
00:39 <iqubic> And the two functions are: toRectange Square x = Rectangle x x
00:40 <iqubic> and toSquare Rectangle x y = if x == y then Just (Square x) else Nothing
00:41 <iqubic> Or something rather similar to that.
00:41 <iqubic> I'd assume
00:41 <iqubic> Not sure how to create a prism though.
00:42 <iqubic> Like i get that Lens s t a b says that when the small part s turns into the small part t, data a becomes data b
00:42 <Cale> sophiag: Okay, so now your problem is that you have map applied to (filter ...) which is a list, rather than a function
00:43 ckubrak joined
00:43 <Cale> sophiag: Maybe you intended to map a particular function over that list?
00:43 <sophiag> yeah, i've solved the error in the second part of filter
00:43 <iqubic> I have no idea what Prism s t a b means.
00:43 pera joined
00:43 <Cale> Or maybe you intended map (filter f) xs
00:43 <sophiag> what i intend is to filter the nested lists inside (map ListVal [ambVal x]))
00:43 <Cale> right
00:43 <Cale> okay
00:43 <sophiag> yes the latter
00:43 <Gurkenglas> http://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Prism.html#v:prism'
00:44 <sophiag> so that appears to be my last error
00:44 <sophiag> although i have a *whole* other issue that will likely prevent me from seeing whether this works...
00:45 <iqubic> Gurkenglas: what the heck is a choice, or do I not need to know for now?
00:45 <iqubic> Is that like how Either a b can be Left a or Right b?
00:45 <iqubic> Or what?
00:46 conal joined
00:46 jgt1 joined
00:47 <iqubic> Also, Gurkenglas that page on Prisms mentions Isos. What are those?
00:47 <Gurkenglas> iqubic, I don't even know; it's what is needed to be able to get back either of the functions of the pair by setting some parameter to some newtype, like lenses use Identity and Const for setting and getting
00:47 <Gurkenglas> @what Choice is
00:47 <lambdabot> I know nothing about choice.
00:48 <iqubic> How does one write a Lens as a Getter and a Setter?
00:48 <Gurkenglas> iqubic, an Iso' s a is a witness that s and a are the same
00:48 <iqubic> Really?
00:48 <Gurkenglas> In the sense of there being functions s -> a and a -> s
00:49 <Cale> iqubic: https://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Prism.html#t:Choice
00:49 <iqubic> I see
00:49 <Gurkenglas> Like, you can build an Iso' (Identity a) a
00:49 <iqubic> Cale: That's a rabbit hole I don't want to dive down.
00:49 <Cale> oh, they don't actually have the methods there
00:49 eacameron joined
00:49 <iqubic> I don't ever know what a profunctor is.
00:50 <Cale> In that case, don't worry about it, all you need to know is that (->) is an instance
00:50 <Gurkenglas> And then there's Equality', which is a witness that two types aren't even kept apart by the compiler. You can build an Equality' a a :P
00:50 <iqubic> Of Choice.
00:50 <Cale> yeah
00:50 <iqubic> Gurkenglas: what does Equality' do?
00:51 <iqubic> Is that like saying there is a type synonym between a and b?
00:51 <Gurkenglas> sure why not
00:51 <iqubic> Is that the simple way of explaining it?
00:53 <Gurkenglas> Mentioning type synonyms makes it seem like that's their purpose, but what Equality' s a does is gurantee that s is a
00:53 <Gurkenglas> (While also being usable as an Iso', Lens' or Prism' if you need that for some reason :P
00:53 <Gurkenglas> *)
00:53 Swizec joined
00:54 <Gurkenglas> (Also Isos can be used as Lenses and Prisms)
00:54 <iqubic> Is this an Iso'?
00:55 <iqubic> toPair f = ((f True), (f False))
00:56 <iqubic> fromPair (x, y) = if True then x else y
00:56 <Gurkenglas> Can be turned into one, yep
00:56 <Gurkenglas> iso fromPair toPair is what does it (or iso toPair fromPair if you want it the other way)
00:56 <iqubic> no '?
00:56 <Gurkenglas> The same function is used to construct Isos and Iso's
00:57 <iqubic> it converts between (a, a) and (Bool -> a)
00:57 <iqubic> I like that.
00:57 <c_wraith> That Iso is just a witness to the equality of x * x and x^2
00:57 <iqubic> really?
00:57 <iqubic> How so?
00:57 <c_wraith> Algebraic interpretation of data types.
00:58 <c_wraith> Product types aren't called that accidentally.
00:58 <c_wraith> They correspond to multiplication.
00:58 <c_wraith> It turns out functions correspond to exponentiation.
00:58 <iqubic> c_wraith: Can I see an example of a product type?
00:58 <c_wraith> (,) is a product type
00:58 <c_wraith> Anything with multiple arguments to the same constructor is a product.
00:58 <Gurkenglas> If the number of values in the result type is x, then the number of possible pairs of values of that result type is x * x
00:58 <bollu> c_wraith: I was thinking about this: do you have any reasonable way to define logarithms?
00:59 safe joined
00:59 <bollu> c_wraith: I was considering log_a(b) = "number of copies of a in b" which works out for a lot of cases
00:59 <c_wraith> bollu: I'm the wrong person to ask about that - I only know the basics.
00:59 <Gurkenglas> And the number of values in a function type with that same result type is x to the power of the number of values in the argument type
00:59 <iqubic> Is (->) a product type?
01:00 <iqubic> or No?
01:00 wroathe joined
01:00 <c_wraith> No. It doesn't have an algebraic constructor. It's a bit weird.
01:00 <Gurkenglas> "a -> b" contains (number of values in b) ^ (number of values in a) values
01:00 <iqubic> Alright.
01:00 orbifx joined
01:00 <Gurkenglas> (disregarding bottom-stuff)
01:01 <Cale> Yeah, it's an exponential.
01:01 <iqubic> So how does an iso act as a lens, or a traversal?
01:02 <iqubic> Wait, Isos aren't traversals, their prisms.
01:02 <iqubic> and Lens's
01:02 <iqubic> How does that work??
01:02 <Gurkenglas> Well prisms are traversals and lenses are traversals so isos are traversals too
01:02 bjz joined
01:02 <c_wraith> Carefully chosen types so that they unify correctly :)
01:02 <iqubic> Can I see the types of these things?
01:03 <sophiag> Cale: i don't understand the errors at this point at all. the two seems totally conflicting: http://lpaste.net/354622
01:03 <c_wraith> @hackage lens
01:03 <lambdabot> http://hackage.haskell.org/package/lens
01:03 <Gurkenglas> http://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Iso.html#t:Iso <- type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)
01:03 <c_wraith> iqubic: I mean, we can point things out, but the types are one of the main things listed in hackage documentation
01:04 bjz joined
01:04 <Gurkenglas> http://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Lens.html#t:Lens <- type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
01:04 <Gurkenglas> An Iso can be treated as a lens by setting p to (->)
01:04 <iqubic> What is the point of Equality a b a b?
01:05 xcmw joined
01:05 peterbecich joined
01:06 <Cale> sophiag: Well, ambVal x :: MultiList
01:06 <Cale> sophiag: But you're applying filter to it, so it must be a list of some sort
01:07 Rodya_ joined
01:07 <iqubic> Gurkenglas: How does one create a prism?
01:08 <sophiag> oh, so since i wrapped the lists in that data type it's failing to typecheck?
01:08 <Gurkenglas> iqubic, you write that in the sort of places where a ~ b. I'd guess that happens once you start needing to be able to let the user choose the types you work with at runtime
01:08 darkSeid_ joined
01:08 <sophiag> i'm doing so much type contortion here. there's got to be a better way. i'd like to get it at least working correctly first tho
01:08 <Gurkenglas> *where you write things like "a ~ b" constraints
01:08 sleffy joined
01:08 <Gurkenglas> iqubic, prism' constructs Prism's
01:09 aarvar joined
01:09 <iqubic> what does that ~ mean?
01:09 <Gurkenglas> That a and b are equal.
01:10 <Gurkenglas> (Not in the (a -> b, b -> a) exists way, in the "those functions are both id" way)
01:10 <iqubic> why does the ~ operator exist, and what does it do???
01:11 <Cale> ~ is type equality
01:11 <Gurkenglas> As I just said, I'm guessing you need that once you stop knowing everything about your types at compile time.
01:12 <Cale> sophiag: Well, values of type MultiList aren't literally lists, they're one of those constructors, applied to a list.
01:13 <sophiag> i think i should use that helper function i made mapMultiList that unwraps them and wraps them back up
01:13 <sophiag> it's not quite working tho
01:13 <Gurkenglas> Like, when you want to write a server whose data structures you can refactor without restarting the server
01:14 Gurkenglas joined
01:14 <Gurkenglas> Can we get ircbrowse out of the topic until it's fixed?
01:15 Wuzzy joined
01:16 wroathe joined
01:16 <Cale> I suppose we could, but how long is it going to be down?
01:18 soniku joined
01:21 blender joined
01:21 richi235 joined
01:22 aarvar joined
01:23 <peterbecich> this alternative to ircbrowse seems to work: http://irclogger.com/.haskell-beginners/2017-04-16
01:24 halogenandtoast joined
01:24 iboss joined
01:24 mr_sm1th joined
01:24 ebzzry joined
01:24 kylepotts joined
01:25 kyren joined
01:26 <xcmw> Which is better freer-effects, extensible-effects, or transformers? I just discovered effects systems and they seem better than monad transformers. Is there a catch?
01:27 wroathe joined
01:28 preyalone joined
01:28 <Gurkenglas> How long has it been down? I'd check when the first complaint was but ircbrowse is down
01:29 <Gurkenglas> (I complained once on 17th march)
01:30 NyanPasu joined
01:33 kyren joined
01:33 <iqubic> What operations can you perform in Isos?
01:33 mazeinmaze_ joined
01:34 MP2E joined
01:34 happy0 joined
01:35 <xcmw> iqubic: Are you talking about the lens library?
01:35 <iqubic> Yes.
01:35 <iqubic> I am indeed.
01:35 <Gurkenglas> rtfm http://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Iso.html
01:35 <ertes> edwardk: why does PlanT in 'machines' have a failure mode?
01:37 <Gurkenglas> (Dont forget that you can consume them in every way that works for traversals prisms and lenses tho)
01:38 <xcmw> iqubic: Iso means you can go from a to b and from b to a. I'm not quite sure what your question is.
01:40 <ertes> iqubic: you can do everything you can do with lenses, but you get an extra operation 'from'
01:40 <ertes> :t _polar
01:40 <lambdabot> (Functor f, Profunctor p, RealFloat a) => p (a, a) (f (a, a)) -> p (Complex a) (f (Complex a))
01:40 <ertes> :t from _polar
01:40 <lambdabot> (Functor f, Profunctor p, RealFloat a) => p (Complex a) (f (Complex a)) -> p (a, a) (f (a, a))
01:41 <ertes> > (0 :+ 1) ^. _polar
01:41 <lambdabot> (1.0,1.5707963267948966)
01:41 <ertes> > (0 :+ pi/2) ^. from _polar
01:41 <lambdabot> error:
01:41 <lambdabot> • Couldn't match type ‘(a, a)’ with ‘Complex Double’
01:41 <lambdabot> Expected type: Getting (Complex a) (Complex Double) (Complex a)
01:41 <ertes> > (0, pi/2) ^. from _polar
01:41 <lambdabot> 0.0 :+ 0.0
01:41 <ertes> > (1, pi/2) ^. from _polar
01:41 <lambdabot> 6.123233995736766e-17 :+ 1.0
01:42 jmcarthur joined
01:44 meba joined
01:44 Supersonic112_ joined
01:46 conal joined
01:47 ebzzry joined
01:48 mkoenig joined
01:48 wroathe joined
01:52 augur joined
01:52 <sophiag> i'm ending up with adts that are both recursive and have data constructors for other adts, which is creating a lot of problems wrapping and unwrapping them. what's the better way to handle these situations?
01:53 <sophiag> it's littering my code with helper functions and greatly overcomplicating things
01:54 <Axman6> can you give an example?
01:54 freebrew81 joined
01:54 <sophiag> sure one sec
01:55 <Gurkenglas> sophiag, have you heard of lens? x)
01:55 <sophiag> ha, yeah i was thinking of lenses
01:56 <peddie> sophiag: perhaps classy lenses / prisms?
01:56 <sophiag> that would at least solve the problem of all the helper functions
01:56 <sophiag> i still feel like i could structure the data better, but idk
01:56 <sophiag> here's a snippet of what i'm dealing with rn: http://lpaste.net/354622
01:57 takle joined
01:58 <sophiag> really, i'd just like to get that function working. but i've come up against problems like this soooo many times in this tiny program it's aggravating
01:58 <sophiag> like it's less than 300 lines and there's even one more adt than that...
01:58 asivitz joined
02:00 mod0 joined
02:00 <peddie> sophiag: I have no idea what's going on in this program yet, but why have MultiList instead of just a list of AmbVals?
02:00 hucksy joined
02:00 <sophiag> because then the lists can be heterogenous
02:01 <peddie> sophiag: line 71, do you want fromJustAmbVal . reqVal r instead of fromJustAmbVal $ reqVal r ?
02:01 <peddie> sophiag: oh, the entire list must be of the same type
02:01 <peddie> ok
02:01 <sophiag> i tried that before, but application is giving me a more sensible error
02:02 <peddie> or perhaps `fromJustAmbVal . reqVal` ?
02:02 <peddie> oh wait
02:02 <peddie> I misunderstood, ignore that
02:02 <peddie> I don't really grasp what this program is doing
02:02 <sophiag> i used composition before just like this and it was fine. but that was in a list comprehension, not as the predicate to filter
02:02 <sophiag> it's part of a dsl
02:03 <sophiag> i could describe the whole thing, but it's really besides the point re: type errors
02:04 wroathe joined
02:05 <peddie> sophiag: so your `filter` call is meant to have a function as its first argument, but instead it has a `Bool`
02:05 <sophiag> oh
02:05 <peddie> the bit in braces doesn't take any arguments
02:05 <sophiag> so i can problem ommit that helper then?
02:05 <sophiag> do you mean parentheses?
02:05 <sophiag> and then...which ones?
02:06 <peddie> `fromJustAmbVal $ reqVal r` is of type `Bool`
02:06 <peddie> :t filter
02:06 <lambdabot> (a -> Bool) -> [a] -> [a]
02:06 <sophiag> ok, so you can see from the types that the function there is not going to work in a filter, right
02:06 <sophiag> hence why i used the helper?
02:07 <peddie> I don't know what you mean when you say "the helper," but I don't understand how any additional code could fix this type mismatch for you
02:07 <sophiag> what?
02:07 <peddie> it's not a function, so it's definitely not going to work in a filter
02:07 <sophiag> haskell is turing complete so, yes, i can write this function
02:08 <sophiag> i provided everything so it's self-explanatory
02:08 <peddie> sophiag: ok, you've totally lost me now :) not sure how turing completeness comes into play here. can we back up and start over?
02:08 <sophiag> you're saying that (AmbVal -> Maybe AmbVal) is not a function?
02:08 <sophiag> that's the type of a function
02:08 <peddie> what value has that type?
02:09 <sophiag> you said "it's impossible"
02:09 <sophiag> the value you've been discussing this entire time
02:09 <sophiag> the one you said isn't a function has that type and so is clearly a function
02:09 <peddie> `reqVal r` has that type, which is a subset of the value I'm discussing
02:09 <sophiag> and it's not the correct type for the predicate to filter
02:10 <peddie> so you're applying `fromJustAmbVal :: Maybe AmbVal -> Bool` to an argument `reqVal r :: AmbVal -> MaybeAmbVal`
02:10 brynedwardz joined
02:10 <peddie> but `fromJustAmbVal` does not want an argument with a function type like that?
02:11 <sophiag> yes, that's why i'm asking a question
02:11 <peddie> shouldn't you rather compose them with `.` and get a value of type `AmbVal -> Bool` ?
02:11 <sophiag> that's no better
02:11 <sophiag> have you tried that?
02:11 <peddie> why not? it seems to me like it would fix the type error
02:11 <peddie> have you? ;)
02:12 <sophiag> <peddie> or perhaps `fromJustAmbVal . reqVal` ? [22:02]
02:12 <sophiag> *** mod0 (~Mutter@ has quit: Client Quit
02:12 <sophiag> <peddie> oh wait
02:12 <sophiag> <peddie> I misunderstood, ignore that
02:12 <sophiag> <peddie> I don't really grasp what this program is doing
02:12 <sophiag> <sophiag> i used composition before just like this and it was fine. but that
02:12 <sophiag> was in a list comprehension, not as the predicate to filter
02:12 <peddie> yes, I remember this, but why is it not fine here?
02:12 <sophiag> you asked me whether i tried it
02:12 <sophiag> twice
02:12 takle joined
02:12 <sophiag> and i'm answering that i did
02:13 kay joined
02:13 <sophiag> it's obvious why it doesn't work. you said it yourself
02:13 <peddie> OK :) that message before made it sound like you only tried it in a list comprehension, not here. what goes wrong when you try it here?
02:13 <peddie> no, the comment of mine I corrected above was `fromJustAmbVal . reqVal`, not `fromJustAmbVal . reqVal r`
02:13 <Axman6> I too find that being agr4ssive to people trying to help you is an effective way to getting further help from them
02:14 <peddie> what error do you get if you replace the `$` with a `.`?
02:14 <Axman6> agressive*
02:14 <sophiag> here's the paste with new errors: http://lpaste.net/354622
02:14 RoyalNightGuard joined
02:14 <peddie> thanks
02:15 <ertes> you know what would be really useful? if the things that http-conduit calls "request lenses" were actually lenses
02:15 <peddie> ah, you need something that will work for any `a`, and your function only works for `AmbVal`, is it?
02:15 <sophiag> peddie: i don't understand what you're referring to
02:16 <sophiag> i'm sorry, i just get fed up quickly with the communications issues in programming. my real life seeping into irc interactions :p
02:16 <peddie> sophiag: `appMultiList` requires an argument with type `[a] -> [a]`, but you're giving it one of type `[AmbVal] -> [AmbVal]`
02:16 <peddie> sophiag: no worries, let's keep truckin' :)
02:16 <peddie> sorry, `forall a. [a] -> [a]`
02:17 <peddie> it's going to be hard to write a filter that works on any possible element type ;)
02:17 <sophiag> it's not any possible type
02:17 <sophiag> it's literally one type
02:17 <peddie> `forall a. [a] -> [a]` means that it has to work for any possible element type
02:17 <sophiag> and changing the type signature of appMultiList just breaks the function
02:18 <sophiag> that's the type signature for that function. are you recommending i write a different function?
02:18 <peddie> sophiag: how does it break it? what if you mapped the appropriate `AmbVal` constructor over the `MultiList` before applying the function, so that then your filter would have the appropriate type?
02:18 wroathe joined
02:18 kylepotts joined
02:19 <peddie> sophiag: no; `appMultiList` will never try to call its argument at type `[()] -> [()]`, for example
02:19 <peddie> there's a closed set of types it can call it at, and they're described by `AmbVal`
02:20 <AWizzArd> Nothing >>= f1 >>= f2 >>= f3 -- none of the f1-f3 gets called. But: are all of the >>= called? Or does the computation end after the first bind?
02:20 <peddie> sophiag: in other words, I think `appMultiList` should be written so that its argument is a function of type `[AmbVal] -> [AmbVal]`
02:21 <sophiag> i think i sort of understand what you're saying, but it's very hard to tell
02:21 <ertes> sophiag: i realise that you have tags in multiple types, which indicates that you may want to abstract it out… there is also a nice utility type for doing that: (,)
02:21 <peddie> AWizzArd: check out the source code for the monad instance for `Maybe`: https://hackage.haskell.org/package/base-
02:21 blender joined
02:22 revprez_atlanta joined
02:23 <ertes> s/abstract/factor/
02:23 <ertes> sophiag: then very quickly both Amb and Require become redundant altogether
02:23 wroathe joined
02:24 <sophiag> how so?
02:24 <ertes> if you factor the tag out of Amb, what remains is Multilist
02:24 <sophiag> you understand this is a snippet, not an entire program, right?
02:24 <AWizzArd> I already saw the code before. My question is more like: „Ah okay, the first >>= returns Nothing. Good, now that we have this value the second >>= can be called, which also results in a Nothing. Now that this val was computed we can call the third >>=.
02:24 <Gurkenglas> sophiag, are you trying to do something like what Data.Dynamic does?
02:25 <sophiag> no
02:25 <sophiag> i don't know what any of these suggestions are
02:25 <AWizzArd> Does it work like this? Or will this short-circuit after the first?
02:25 <sophiag> i'm trying to fix one type error
02:25 <ertes> woah, sorry, i'll shut up again
02:26 ubsan_ joined
02:26 <Gurkenglas> > sequenceA $ repeat Nothing -- AWizzArd, as you see, it doesn't traverse all of the infinite list :)
02:26 <peddie> AWizzArd: doesn't look like it short-circuits to me
02:26 <lambdabot> Nothing
02:29 <AWizzArd> Gurkenglas: and how is this happening?
02:29 isd joined
02:31 <peddie> AWizzArd: I think I'm still asleep or something, but it's probably to do with the associativity of >>=
02:32 <AWizzArd> Is Nothing >>= f1 >>= f2 >>= f3 === ((Nothing >>= f1) >>= f2) >>= f3
02:33 <peddie> yeah, that's why I said I didn't think it short-circuited
02:33 <peddie> hmm
02:33 <AWizzArd> Yes. But Gurkenglas showed it does.
02:33 <peddie> right
02:34 augur joined
02:34 indi_ joined
02:35 <Gurkenglas> sequenceA (repeat Nothing) = traverse id (repeat Nothing) = (foldr cons_f (pure []) (repeat Nothing) where cons_f x ys = (:) <$> id x <*> ys) = (cons_f Nothing (foldr cons_f (pure []) (repeat Nothing)) where cons_f x ys = (:) <$> id x <*> ys) = ((:) <$> id Nothing <*> (foldr cons_f (pure []) (repeat Nothing)) where cons_f x ys = (:) <$> id x <*> ys) = (Nothing <*> (foldr cons_f (pure []) (repeat Nothing)) where
02:35 <Gurkenglas> cons_f x ys = (:) <$> id x <*> ys) = Nothing
02:35 des joined
02:35 <* peddie> hands Gurkenglas a barf bag
02:38 <Gurkenglas> Hmm but that wasn't quite the question was it. a >>= b >>= c >>= d >>= e associates to ((((a >>= b) >>= c) >>= d) >>= e) meaning that that one does pass all the Nothing's through.
02:38 <peddie> it seems like it must
02:38 <peddie> but it works fine on infinite lists, so we're missing something!
02:38 xcmw joined
02:39 <nshepperd> sequenceA (Nothing : xs) = Nothing >>= (\a -> (a:) <$> sequenceA xs)
02:39 <peddie> oh, I see
02:39 <peddie> thanks nshepperd
02:40 <nshepperd> :)
02:40 <glguy> sequenceA doesn't use >>=
02:41 benl23 joined
02:41 <glguy> :t sequenceA
02:41 <nshepperd> oh yeah. well, whatever
02:41 <lambdabot> (Applicative f, Traversable t) => t (f a) -> f (t a)
02:42 <nshepperd> I guess it's more like sequenceA (Nothing : xs) = (:) <$> Nothing <*> sequenceA xs
02:42 <nshepperd> although these should be the same if Maybe obeys the monad laws
02:42 <peddie> glguy: <*> is defined on the Nothing case so that it works the same as >>=, I think you have to do it that way
02:42 <nshepperd> i guess
02:43 blender joined
02:45 mizu_no_oto joined
02:45 <peddie> AWizzArd: did you catch that?
02:46 takle joined
02:48 <AWizzArd> I think I can take something from this.
02:48 <AWizzArd> Anyway, I just thought I will better test this.
02:49 <AWizzArd> So I implemented my own operator, by copying the implementation of (>>=) for Maybe.
02:49 <peddie> AWizzArd: the reason Gurkenglas' example short-circuited was due to the definition of `sequenceA`, not the `>>=` operator
02:49 <AWizzArd> But I put a trace in there.
02:49 <AWizzArd> peddie: yes.
02:49 richi235 joined
02:49 <peddie> ok cool
02:49 <AWizzArd> The trace showed me: the Nothings get threaded through.
02:49 <sophiag> peddie: i fixed that error...by making the types even more convoluted :p
02:49 <AWizzArd> My >>= clone does get called as many times it shows up.
02:50 <peddie> sophiag: yikes! does the program work now?
02:50 <sophiag> ha. not how i want it too
02:50 <sophiag> *to
02:50 ericmathison joined
02:50 <sophiag> i'm not certain whether it's because of that line... what i needed was: AList $ filter (fromJustAmbVal . reqVal r) [ListVal $ ambVal x]
02:50 <peddie> sophiag: on further reflection, it seems like the problem is that `AmbVal` and `MultiList` are related (they cover the same closed set of types), but they are independent as far as the type system is concerned
02:51 <sophiag> where AList is...you guessed it...a data constructor to wedge AmbVal into MuliList :p
02:51 <sophiag> yeah, so maybe a not too complicated improvement would be to just combine those two adts?
02:52 <peddie> sophiag: somehow, yes. maybe you could make AmbVal take a type argument and use ordinary lists of them, so that you can't mix types?
02:52 <sophiag> at least then i wouldn't have to wrap each with each other
02:52 <sophiag> oh...i can't remember if there's a reason i didn't think of that
02:52 <sophiag> it sounds so simple now...
02:53 <sophiag> anyway, i'm not sure if in that expression i fixed whether it means it's now filtering for the *whole* list rather than nested lists inside it
02:54 <sophiag> that could explain my problem...i do obviously have an extra set of brackets
02:54 <sophiag> it's either that or a parsing error...
02:54 xcmw joined
02:54 <sophiag> i'd like to rule out the easy part first :)
02:54 eMapM joined
02:55 <eMapM> hey all; with esqueleto, has anyone tried to group on the dd/mm/yyyy part of a date?
02:55 <eMapM> it doesn't seem supported
02:56 meandi_2 joined
02:57 <eMapM> i'm using postgres, so i'm wondering if there's a nice hack to just append `::date` onto my given field
02:57 wroathe joined
02:57 hybrid joined
02:58 <miaumiau> what the frickity fuck am I doing wrong here so that the instance cannot be found: http://imgur.com/dgx1SaH
02:59 <ertes> miaumiau: i don't see any reader there
02:59 <miaumiau> with full buffers, forgot to show the language pragmas http://imgur.com/p7CFHF5
02:59 <ertes> miaumiau: 'components', as far as i can tell, is a list
02:59 <miaumiau> that's the plan, right?
02:59 exferenceBot joined
03:00 <ertes> miaumiau: but you're defining components = ask
03:00 <ertes> :t ask
03:00 <lambdabot> MonadReader r m => m r
03:00 <ertes> there is no MonadReader instance for []
03:00 <miaumiau> mind you, I'm just starting with Haskell
03:00 <miaumiau> apologies if I'm missing something obvious
03:01 <miaumiau> there is one in the bottom window, isn't it
03:01 <ertes> miaumiau: explain what you're trying to do
03:01 <miaumiau> and I import it by importing World
03:01 <ertes> ah, you're actually defining one, but that doesn't sound right
03:01 <miaumiau> get a global instance of the Reader monad for a given type T that has a Component instance
03:01 <ertes> there *should* be no MonadReader instance for []
03:02 <Cale> That instance doesn't make sense
03:02 <ertes> you might be misunderstanding the purpose of MonadReader
03:02 <miaumiau> bottomline I'm trying to reproduce this snippet: https://gist.github.com/memoizr/d197d30b0caad1d2b6fa9c195b74210f
03:03 <miaumiau> yes, that may be the case
03:03 xall_ joined
03:03 permagreen joined
03:03 <ertes> trying to do OOP in haskell is a recipe for sadness
03:03 <Cale> why are my eyes bleeding, what happened?
03:04 <ertes> not just because OOP is… sad… but because haskell doesn't support OOP
03:04 takle joined
03:04 hexagoxel joined
03:04 <Cale> Well, this is scala code, let's try and work out what the heck it says
03:04 <Cale> It *might* be reasonable to translate it to Haskell somehow
03:04 <sophiag> good Scala code seems just like super ugly Haskell to me
03:05 <sophiag> i guess bad Scala is like Java but less ugly
03:05 <ertes> my instinct says that you should start by defining the types in haskell while factoring out common fields
03:05 <ertes> i can't really tell what is a type and what is a field though
03:06 <miaumiau> there's no OOP that I can see
03:06 <miaumiau> on the snippet
03:06 <ertes> miaumiau: i can only guess, but i see an "extends" there
03:06 <miaumiau> it's a tag
03:06 <ertes> and i see "trait", too
03:06 sigmundv_ joined
03:07 <ertes> miaumiau: can you translate just the types to haskell? without the operations
03:07 <miaumiau> I've reverted it in Haskell by making Component a typeclass that fetches the Entity, instead of the other way around
03:07 <Cale> miaumiau: Well, let's see if I can mimic what I think this is saying
03:07 <Cale> is Reader in Scala the same thing it is in Haskell?
03:07 <miaumiau> yes
03:08 <Cale> So a Reader[EntityId, Option[B]] basically the same thing as a function which takes an EntityId and produces an Option[B]?
03:08 <miaumiau> yes
03:08 <Cale> is*
03:08 <Cale> okay
03:08 <miaumiau> reader (\id -> Just B)
03:08 <ertes> so Reader in scala is (->) in haskell
03:09 <miaumiau> Kleisli?
03:09 <Cale> Just regular function arrow
03:09 <ertes> no, (->) is a family of reader monads
03:09 <Cale> You *could* use Reader, but you probably wouldn't here
03:09 <miaumiau> okok
03:09 <ertes> ask = id
03:10 <ertes> > (do x <- sin; y <- cos; pure (x^2 + y^2)) 5
03:10 <lambdabot> 0.9999999999999999
03:11 <miaumiau> why pure and not return?
03:11 <Cale> no good reason
03:11 <miaumiau> ok
03:11 <ertes> i consider 'return' a historical mistake, not because of its name, but because it's in Monad
03:11 pera joined
03:11 govg joined
03:11 <ertes> i've been using 'pure' since The Great AMP
03:11 <miaumiau> Ap fixes it, right?
03:11 <Cale> Well, you're using (>>=) there, so it's a moot point
03:11 <miaumiau> ye
03:12 <ertes> sure… i'm almost surprised nobody "fixed" my code by rewriting it to applicative style =)
03:12 augur joined
03:13 <Cale> I actually like 'return' a whole lot more as a name than 'pure', just because I'm usually thinking in a computational mindset, and like the fact that return v is the action which does nothing except to return v :)
03:14 <ertes> i don't mind the name either… it's only the type of 'return' that bothers me =)
03:14 <ertes> miaumiau: ":" in scala means "of type"?
03:14 stevebash joined
03:14 <Cale> yes
03:14 <Cale> and it has the function(arguments): resultType thing
03:15 <ertes> and "object" defines a type along with its fields and associated procedures?
03:15 felixsch_ joined
03:15 <miaumiau> <: Type is covariant fixation
03:15 <Cale> Yeah, that's not going to have a corresponding thing in Haskell
03:16 <miaumiau> object is a singleton, they're generally used as namespaces
03:16 <Cale> You might be able to get away with just a Component type of some sort though
03:16 <ertes> ah, so it corresponds to something like a module
03:16 takle joined
03:16 <sophiag> that's interesting
03:16 <miaumiau> not necessarily, it can also be an actual instance of a type
03:16 <sophiag> i was thinking about that recently: how classes in most OOP languages are essentially used as namespaces
03:17 <miaumiau> OOP is procedural with classes as namespaces
03:17 <Cale> data Entity = Entity { getComponent :: (EntityId -> Maybe Component) -> Maybe Component } -- maybe something along these lines? I've left the entityId itself out, maybe we'd rather keep it
03:17 <miaumiau> the more mature the codebase, the more static global helpers it has
03:17 <sophiag> Clojure just overloads the term namespace for that instead of having modules, but then the problem is they can't use them as the unit of composition so use functions instead, which brings all kinds of trouble
03:17 <miaumiau> and the client code is just a procedural hydra hidden in hundreds of classes
03:18 harfangk joined
03:18 <sophiag> i sort of wish i had learned Scala for work purposes before i learned too many adjacent languages to care :/
03:18 <ertes> miaumiau: my problem is: right now i would translate this code to a unit type
03:18 <ertes> data Component = Component
03:18 <miaumiau> cale, I had something like that like 6 hours ago hahaha
03:19 <ertes> unless i really suck at reading scala code, there is no actual semantics
03:19 <Cale> Component probably needs to be a record of operations of some sort
03:19 <Cale> But I don't know which operations from this code
03:19 <ertes> yeah, perhaps with a separate type for component ids
03:19 <ertes> and perhaps a type argumen to tie the knot
03:20 <miaumiau> type EntityId = Int -- newtype Entity = Entity EntityId
03:20 <ertes> data Component x = Component -- such that Fix Component would be a graph of all components
03:20 <miaumiau> missing from the screenshot
03:20 <ertes> miaumiau: i'm assuming you're modelling a game of some sort?
03:21 <miaumiau> there's a hard restriction, all the components of a single type must be packed together in an array
03:21 <Cale> miaumiau: I've come to regard the heart of traditional object oriented programming as simply programming which places an emphasis on defining data in terms of operations for taking it apart (methods, or messages)
03:21 <miaumiau> just one array per program
03:21 <miaumiau> yep
03:21 <ertes> why an array?
03:21 SimpleL joined
03:21 <miaumiau> in C++ because CPU cache misses are apparently one of the largest causes of perf loss
03:22 <ertes> i would leave that to GC and use an IntMap
03:22 <miaumiau> so if you model things as Entities witha list of Components, you kind of miss the point of ECS
03:22 <Cale> If you care about CPU cache misses, just turn back now
03:22 <miaumiau> well nobody said I was sane
03:22 wroathe joined
03:22 <miaumiau> I know the parf tradeoffs, doesn't mean it isn't wort trying to model it xD
03:23 <ertes> GHC is actually reasonably good at keeping data together with the caveat that IntMap is fairly large
03:23 pavonia joined
03:23 <miaumiau> type safety is actually a missing part in ECS, many of the implementation rely on reflection and such
03:23 <ertes> but mutable vectors have their own caveat: fast removal, fast insertion, pick one
03:23 pwnz0r joined
03:24 dfeuer joined
03:24 nickmccurdy joined
03:24 <miaumiau> I'd guess that fast addition is preferable in games, but it also has more deletions than your normal system
03:24 <Cale> miaumiau: So the first question I would want to tackle is how to translate B <: Component into Haskell. My first approach would be to say "fuck subtypes", and just see if I can get away with defining a single record of methods that every component will have, and then various ways of producing such records.
03:24 mac10688 joined
03:25 <ertes> insertions and deletions will be about the same on average
03:25 <ertes> anything else and you will either run out of objects or of RAM =)
03:25 <miaumiau> cale, I'd sin it around
03:25 <Cale> hm?
03:25 takle joined
03:25 <miaumiau> I'd swap it around
03:25 nickmccurdy left
03:25 <miaumiau> so instad of entities fetching components
03:25 <miaumiau> components contain their associated entity
03:26 <Cale> That's also possibly reasonable
03:26 <ertes> miaumiau: that's the point of my parametric Component
03:26 <miaumiau> so for a system you traverse all the components array
03:26 <ertes> data Component x = Component { parent :: x, draw :: IO () }
03:26 <miaumiau> no need to draw
03:27 <ertes> Component CompKey -- here is a component that only has the key of its parent
03:27 <miaumiau> draw is a system
03:27 <miaumiau> for all Entities with components Renderable, Sprite, Position, or however you define it
03:27 <ertes> then you can use 'traverse' to turn Component CompKey into Component (Component CompKey)
03:27 <miaumiau> that's the missing piece of the puzzle
03:27 <ertes> to get the first layer of parents
03:27 feynhat joined
03:28 <ertes> uhm… i guess (parent :: Maybe x) makes more sense =)
03:28 <miaumiau> components can only be created with an associated entity
03:28 <miaumiau> no maybe needed
03:28 <miaumiau> and x is always EntityId
03:28 hamishmack joined
03:28 <miaumiau> there's no need to fetch a full entity, the id is enough
03:28 <ertes> what's the difference between components and entities?
03:29 <miaumiau> if you need it, you poll the world to fetch whatever component for an entityid
03:29 <miaumiau> it's really a thin abstraction
03:29 <miaumiau> an entity is an identity of anything in a world
03:29 <miaumiau> the entity has N components associated to it
03:30 <miaumiau> and the system processes all components that fulfill an aspect (sum of components for a single identity)
03:30 <sveit> i am trying to understand the State monad, so I wrote my own and am comparing with the built-in version. i do not understand why in this code: http://lpaste.net/8156431319337795584 testMyStrict overflows but testBuiltInStrict doesn't. i don't see the (conceptual, my implementation is slightly different) difference between my code and the built-in classes. does anyone see the problem?
03:30 <ertes> so a player would be an entity, and, say, their set of weapons would be components?
03:30 Rodya_ joined
03:30 otto_s joined
03:30 <miaumiau> so a system is basically process:: a -> b -> c -> EntityId -> World -> World
03:31 <miaumiau> where a, b, c are components
03:31 <miaumiau> and there can be any number of, from 0 to however many components your system understands
03:31 MrWoohoo joined
03:31 <miaumiau> that's another thing I have to investigate how to do
03:31 <miaumiau> I do't see myself writing a System1, System2, System3 etc... if there's variadic polymorphism
03:32 <sophiag> Cale: do you want to see where i got with that problem from earlier? i fixed it, but it's misbehaving. i think the types i've defined are just far too messy at this point, although i got some good feedback on that
03:32 <miaumiau> ertes a player would be the entity with the Player component, which would have an inventory component, and the inventory can model whatever
03:33 <miaumiau> or maybe instead of an inventory component you prefer a sword component...the ida is to have a generalization
03:33 <miaumiau> and that also applies to part of the simulation, like speed, position in screen and world
03:34 <miaumiau> or the path to the sprite to be painted on screen
03:34 <ertes> miaumiau: i'm not sure i understand the distinction… or the utility of that distinction
03:34 systemfault joined
03:34 <ertes> miaumiau: do you mean that an entity is just a key?
03:34 <miaumiau> yep
03:34 <miaumiau> that's the implementation detail
03:34 teggi joined
03:35 <miaumiau> https://github.com/junkdog/artemis-odb/blob/master/artemis/src/main/java/com/artemis/Entity.java
03:35 <miaumiau> a component is literally whatever: https://github.com/junkdog/artemis-odb/blob/master/artemis/src/main/java/com/artemis/Component.java
03:36 <ertes> then Component is the actual implementation detail, as far as i see
03:37 <miaumiau> and a system is a glorified reduce: https://github.com/junkdog/artemis-odb/blob/master/artemis/src/main/java/com/artemis/BaseSystem.java#L43
03:37 <miaumiau> yeah
03:37 <ertes> let's say you want to use traditional imperative style to implement the game logic… then i'd most likely use a StateT (if at all) to keep an IntMap to all the current entities in the game: IntMap (Entity Key)
03:38 <miaumiau> simple, you reduce on that StateT
03:38 <miaumiau> that's what I'm calling world
03:38 <ertes> where: data Entity k = Entity { draw :: IO (), parent :: Maybe k }
03:38 <miaumiau> so you process all your reducers (systems) to modify the world
03:38 <miaumiau> and at the end of the frame, you paint whatever is on the world
03:38 capicue joined
03:39 <miaumiau> so only one reduce per game tick, which is the tricky part
03:39 <miaumiau> game has to run at 60fps, which means all processing has to be within 16ms
03:39 <ertes> well, yeah, you also need a frame operation
03:39 <ertes> data Entity k = Entity { draw :: IO (), frame :: TimeDelta -> IO (Entity k), parent :: Maybe k }
03:40 <ertes> the actual frame is a 'traverse' over the IntMap
03:40 <miaumiau> where do you store the relations between the intmap and their components
03:40 <ertes> what does that mean?
03:41 <miaumiau> sorry, what's an intmap
03:41 <miaumiau> is it like a sparsemap
03:41 <miaumiau> an int -> value kind of deal
03:41 <ertes> i don't know what a sparsemap is, but it's a radix tree-based implementation of an association data structure
03:41 <miaumiau> that allocates space equal to the largest number?
03:41 <miaumiau> okok
03:41 <ertes> yeah: (IntMap k a) behaves like (Int -> Maybe a)
03:42 <miaumiau> nice and fast, cool
03:42 <miaumiau> are updates just modifications of nodes in the tree, a la clojure?
03:43 <ertes> an update is a modified copy, but the copy shares most of the tree with its ancestor
03:43 <miaumiau> yep
03:43 blender joined
03:43 <miaumiau> same, or sameish at least
03:43 <miaumiau> that's a library data structure, right?
03:44 <ertes> it's in Data.IntMap in 'containers'
03:44 <ertes> @package containers
03:44 <lambdabot> http://hackage.haskell.org/package/containers
03:44 <miaumiau> great
03:44 <miaumiau> I have to get going, it's 5 am and I'm pretty sure I skipped dinner
03:44 <miaumiau> can't remember
03:44 <miaumiau> I'll take another look tomorrow, a bit more fresh
03:44 <miaumiau> thank you for the help
03:45 <ertes> feel free to idle in #haskell-game, if you want =)
03:45 <miaumiau> oh wow the legend is true
03:46 <miaumiau> there're people more crazy than I am :D
03:46 <ertes> not that a lot is going on there, but at least most people interested in haskell game dev are there =)
03:46 diegoksp joined
03:47 <sveit> sorry to bump, but does anyone see why in http://lpaste.net/8156431319337795584 testMyStrict stack overflows but testBuiltInStrict does not?
03:48 stevebash joined
03:49 justanotheruser joined
03:50 Wuzzy joined
03:51 blender joined
03:52 <iqubic> Does (,) have a functor instance?
03:53 kamyar joined
03:53 <sveit> iqubic: yes
03:53 <kamyar> Hello all
03:53 <kamyar> PLease help me use MessagePack
03:53 <sveit> well ((,) b) does
03:54 <iqubic> What I want is a function with this type signature: Applicative f => (a -> c) -> (b -> d) -> f a b -> f c d
03:54 <kamyar> I just want to pack (serialize) some object into MessagePack
03:54 <jle`> iqubic: that's not well-kinded
03:54 <iqubic> It it not?
03:54 <jle`> yes
03:54 <iqubic> What do you mean?
03:54 <jle`> Applicatives are all * -> *
03:54 <jle`> but f there is * -> * -> *
03:54 <jle`> that is, Applilcatives are things that take one argument
03:54 <iqubic> Oh.
03:55 <jle`> Maybe, IO, Either e, etc.
03:55 <jle`> that's the only way the type for 'pure' and <*> would make sense
03:55 <jle`> :t pure
03:55 <lambdabot> Applicative f => a -> f a
03:55 <jle`> you might be interested in Bifunctor
03:55 <iqubic> So how do I write a function like: (a -> c) -> (b -> d) -> (a, b) -> (c, d)
03:56 <jle`> iqubic: that one isn't too hard
03:56 <iqubic> Is it not?
03:56 <jle`> :t \f g (x, y) -> (f x, g y)
03:56 <lambdabot> (t3 -> t2) -> (t1 -> t) -> (t3, t1) -> (t2, t)
03:56 <iqubic> Oh.
03:56 <jle`> :t \f g (x, y) -> (f x, g y) :: (a -> c) -> (b -> d) -> (a, b) -> (c, d)
03:56 <lambdabot> error:
03:56 <lambdabot> • Couldn't match expected type ‘(a1 -> c1)
03:56 <lambdabot> -> (b1 -> d1) -> (a1, b1) -> (c1, d1)’
03:56 <jle`> :t (\f g (x, y) -> (f x, g y)) :: (a -> c) -> (b -> d) -> (a, b) -> (c, d)
03:56 <lambdabot> (a -> c) -> (b -> d) -> (a, b) -> (c, d)
03:57 <jle`> iqubic: but this function is already provided in base (twice, actually) so you don't have to write it yourself
03:57 connrs joined
03:58 jgt1 joined
03:58 <iqubic> What if I want to make it generic? Like have it work with and Data tyoe that can be constructed with two arguments, and not just tuples.
03:58 <iqubic> Is that what bifunctor does?
03:58 infinity0 joined
03:58 <jle`> :t bimap
03:58 <lambdabot> Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
03:59 <jle`> yeah, it abstracts over things that are functors in both arguments
03:59 <jle`> it's not the most useful abstraction though, because there really aren't that many useful instances
03:59 <jle`> so writing 'generic' code isn't particularly useful
04:00 aarvar joined
04:00 <iqubic> Yeah, what I want here is actually a traversal over my data.
04:00 <iqubic> I want to apply the same function to both parts.
04:00 <iqubic> I have a custom data type, and I need to make a traversal for it.
04:00 <jle`> is your data type a specific type?
04:00 <jle`> it'd probably be easiest to just write it non-generically
04:00 <dfeuer> sveit: your Applicative instance smells lazier than the one in transformers, but I haven't analyzed it fully.
04:01 <iqubic> jle`: It's a specific type that I defined for my own program.
04:01 <iqubic> And I need a way to traverse it.
04:01 <jle`> best way is probably to write a traversal
04:01 <jle`> by pattern matching etc.
04:01 <iqubic> newtype Scale = Scale a a
04:01 infinity0 joined
04:01 <iqubic> It looks like that.
04:02 xcmw joined
04:02 <jle`> except different, right
04:02 <jle`> like data Scale a = Scale a a ?
04:02 <sveit> also, why is (snd $ flip runState 0 $ replicateM_ (10^7) (modify' (+1) >> get)) slow, even when i only import Control.Monad.State.Strict?
04:02 <iqubic> yeah, jle` that's what it looks like.
04:02 <iqubic> data Scale a = Scale a a
04:03 <jle`> yeah, you can probably just write a traversal by hand by pattern matching on the constructor
04:03 <iqubic> I can?
04:03 <jle`> traverseScale f (Scale a) = Scale <$> f a <*> f a
04:03 <jle`> er sorry
04:03 <jle`> traverseScale f (Scale x y) = Scale <$> f x <*> f y
04:04 <iqubic> Yeah, just because the two arguments are the same type doesn't mean they have the same value.
04:04 <jle`> GHC can actually derive this traversable for you
04:04 <iqubic> jle`: What would the type of that traversal be?
04:04 takle joined
04:04 <jle`> the most generic type would be Applicative f => (a -> f b) -> Scale a -> f (Scale b)
04:04 infinity0 joined
04:04 <iqubic> jle`: What do you mean GHC can derive that for me?
04:04 <jle`> or Traversal (Scale a) (Scale b) a b
04:05 <jle`> @let data Scale a = Scale a a deriving (Show, Functor, Foldable, Traversable)
04:05 <lambdabot> Defined.
04:05 <jle`> :t traverse :: Applicative f => (a -> f b) -> Scale a -> f (Scale b)
04:05 <lambdabot> Applicative f => (a -> f b) -> Scale a -> f (Scale b)
04:05 <sveit> dfeuer: thanks, i think it is as strict though. in any case i expanded my applicative definition and still get the overflow
04:05 <iqubic> It can just do that for me???
04:05 <dfeuer> liftA2 is arriving soon to an Applicative class near you :-)
04:06 <jle`> iqubic: yeah, because the process is really mechanical
04:06 <iqubic> How do I use the infix functions with that data?
04:06 <jle`> what data
04:06 <sveit> dfeuer: do you understand why the code is slow in either case in GHCI? replicateM_ is implemented as a loop, there shoudldn't be a data structure created, right?
04:06 <jle`> infix functions are just normal functions
04:06 <jle`> so you can use them with anything
04:06 thepreacher joined
04:06 <jle`> @let Scale x y +/+ Scale a b = Scale (x + a) (y + b)
04:06 <iqubic> jle`: I mean how do I traverse over a scale using the infix function?
04:06 <lambdabot> Defined.
04:06 <jle`> iqubic: can you show a specific example
04:06 <jle`> of what you mean
04:07 infinity0 joined
04:07 <jle`> but yea,h GHC can derive the Traversable instance because the traversal is extremely mechanical
04:07 <jle`> (1) pattern match on each constructor, and apply f to everything of the right type
04:07 splanch joined
04:07 <jle`> traverse f (Scale x y) = Scale <$> f x <*> f y
04:07 <dfeuer> sveit: no, I don't, but you're comparing compiled code to interpreted... Some optimization is presumably helping.
04:07 xcmw joined
04:07 sigmundv joined
04:07 <jle`> so mechanical that a computer could do it :)
04:08 <jle`> so mechanical that a machine could do it
04:09 <iqubic> How do I apply the infix traverse functions to my traversable scale?
04:09 <jle`> can you give an example of an infix traverse function
04:09 biglambda joined
04:09 <jle`> i'm not sure what you mean
04:10 infinity0 joined
04:10 <iqubic> :t ^..
04:10 <lambdabot> error: parse error on input ‘^..’
04:11 <iqubic> Darn lambdabot doesn't have that???
04:11 <jle`> :t (^..)
04:11 <lambdabot> s -> Getting (Endo [a]) s a -> [a]
04:11 <iqubic> I see.
04:11 <iqubic> cool
04:11 <jle`> well...traverse is just a normal Traversal
04:11 <jle`> so you can use it where you'd use any old traversal
04:11 conal joined
04:11 <iqubic> :t traverse
04:11 <jle`> > Scale 10 3 ^.. traverse
04:11 <lambdabot> (Applicative f, Traversable t) => (a -> f b) -> t a -> f (t b)
04:11 <lambdabot> [10,3]
04:11 <jle`> or Scale 10 3 ^.. traverseScale
04:11 <jle`> whatever you named it
04:12 <iqubic> jle` isn't ^.. just the infix version of toListOf?
04:12 <jle`> yes
04:12 <jle`> it is
04:12 <jchia_1> Can I get a code review? I'm making a type to support the notion of an IO action where I implicitly change directory to "/" before peforming the action itself. http://lpaste.net/354630
04:12 <jle`> iqubic: you can check the documentation if you aren't sure :)
04:12 <jle`> lens documentation is actually pretty clear/concise
04:12 infinity0 joined
04:12 <iqubic> What if I want to add five to both numbers in the scale, while traversing it.
04:13 <jchia_1> When I sequence two actions with >> or >>=, only one cd "/" is performed in the beginning.
04:13 <iqubic> jchia_1: Can we see some code?
04:13 <jchia_1> iqubic: In the lpaste
04:14 <iqubic> jchia_1: What lpaste?
04:14 <jchia_1> http://lpaste.net/354630
04:14 <jle`> iqubic: what do you mean 'while traversing it'
04:15 <jle`> "traversing" is a pretty vague word here
04:15 <jle`> you can add five to both numbers using fmap, or over traverse
04:15 <jle`> > over traverse (+5) (Scale 10 4)
04:15 <lambdabot> Scale 15 9
04:15 <iqubic> Over is the function I was missing.
04:15 <jle`> or just fmap (+5) (Scale 10 4)
04:15 <glguy> traverse is more power than over needs
04:15 <iqubic> wait, why does fmap work in this case?
04:16 <jle`> iqubic: because Scale has a Functor instance
04:16 <iqubic> glguy: How would you have done it?
04:16 <iqubic> jle` So I don't need a traversal?
04:16 <jle`> you never need a traversal
04:16 <glguy> over just needs 'mapped'
04:16 <iqubic> > (Scale 2 3) <$> (+5)
04:16 <lambdabot> error:
04:16 <lambdabot> • Couldn't match expected type ‘a -> b’
04:16 <lambdabot> with actual type ‘Scale Integer’
04:16 <jle`> iqubic: what do you think you need a traversal for?
04:17 <jle`> you never *need* it
04:17 <jle`> it's just very useful and convenient :)
04:17 <iqubic> I'm actually not sure anymore.
04:17 <jle`> it's a useful combinator
04:17 wroathe joined
04:17 <jle`> for manipulating your data type
04:17 <iqubic> Why didn't my infix fmpa work?
04:17 <iqubic> *fmap
04:17 <jle`> iqubic: check the type of (<$>)
04:17 <jle`> the error message is also pretty clear
04:17 <iqubic> (+5) <$> (Scale 1 2)
04:18 <jle`> did you see the error message?
04:18 <iqubic> > (+5) <$> (Scale 1 2)
04:18 <lambdabot> Scale 6 7
04:18 <iqubic> I is stupid
04:18 <jle`> (<$>) expected a function, but you gave it a Scale Integer
04:18 <jle`> nah :)
04:18 <jle`> just good to take things slow
04:18 <iqubic> Is there an infix function that will call over, but add some number n to the elements too?
04:18 <jle`> if something gives an error, try reading the error message, checking types, etc.
04:19 <jle`> > Scale 10 5 +~ 3
04:19 <lambdabot> error:
04:19 <lambdabot> • Couldn't match type ‘Scale Integer’
04:19 <lambdabot> with ‘(Integer -> Identity Integer) -> s -> Identity t’
04:19 <jle`> > Scale 10 5 & traverse +~ 3
04:19 <lambdabot> Scale 13 8
04:19 <glguy> > (mapped +~ 3) (Scale 10 5)
04:19 <lambdabot> Scale 13 8
04:19 <iqubic> :t mapped
04:19 <lambdabot> (Functor f, Settable f1) => (a -> f1 b) -> f a -> f1 (f b)
04:19 xall_ joined
04:19 <iqubic> :t &
04:19 <lambdabot> error: parse error on input ‘&’
04:19 <iqubic> :t (&)
04:19 <lambdabot> a -> (a -> b) -> b
04:19 <iqubic> I see.
04:20 <iqubic> What does mapped do?
04:20 <iqubic> glguy: looking at you.
04:20 <jle`> mapped uses the Functor instance instead of the Traversable instance
04:20 <iqubic> You used mapped just now.
04:20 <glguy> Look at the documentation firsr
04:21 <jle`> > over mapped (+3) (Scale 3 10)
04:21 <iqubic> glguy: So I can use mapped without needing my data type to be an instance of traversable?
04:21 <lambdabot> Scale 6 13
04:21 <jle`> 'mapped' just needs a Functor instance
04:22 JuanDaugherty joined
04:22 <iqubic> :t (+~)
04:22 <lambdabot> Num a => ASetter s t a a -> a -> s -> t
04:22 SimpleL joined
04:23 <iqubic> so I don't need a traversal instance for my data to do this:
04:23 <iqubic> > (mapped +~ 3) (Scale 1 1)
04:23 <lambdabot> Scale 4 4
04:23 <iqubic> :t (mapped +~ 3)
04:23 <lambdabot> (Functor f, Num b) => f b -> f b
04:23 <jle`> yup. mapped uses the Functor instance.
04:24 <iqubic> So why does anyone create a traversal then?
04:24 halogenandtoast joined
04:24 <jle`> when you want to do things that traversals can do
04:24 <iqubic> What other things can traversals do that can't be done with mapped?
04:24 <jle`> see the documentation http://hackage.haskell.org/package/lens
04:25 <jle`> mapped is a Setter, so it can do all of the things in the Setter box
04:25 <ertes> incoming rant
04:25 <jle`> over, set, +~, etc.
04:25 <glguy> Look in the module Control.Lens.Traversal to see consumers of Traversals
04:25 <jle`> but it can't do any of the things in the Traversal box
04:25 <ertes> STOP REINVENTING Either! JUST USE FUCKING Either!
04:26 <ertes> sorry
04:26 <iqubic> What code are you looking at?
04:26 <jle`> iqubic: traversals can be used as Folds and Getters, too, so look at everything in the Fold box, and those are things that traversals can do that 'mapped' can't
04:26 <iqubic> Wait, if I have a traversal instance, I can also use foldL with it?
04:27 <iqubic> And other stuff like that??
04:27 <jle`> yeah, foldrOf, foldlOf, etc.
04:27 <jle`> look at the boxes
04:27 <iqubic> I will
04:27 <jle`> the arrows say "can be used as..."
04:27 <jle`> and the things in the boxes are the things you can do with them
04:28 <iqubic> I see.
04:28 <iqubic> Makes a lot of sense.
04:28 <jle`> for example, Prisms can be used as traversals, folds, and setters
04:28 dan_f joined
04:28 <iqubic> I know.
04:29 <iqubic> Not too sure what a prism is, but I'm learning slowly.
04:29 <iqubic> What does the anyOf function do?
04:29 <iqubic> returns true if an element passes the test?
04:30 <jle`> i know one way to find out
04:30 <iqubic> > anyOf (== 1) (Scale 1 3)
04:30 <lambdabot> error:
04:30 <lambdabot> • Couldn't match type ‘Bool’ with ‘s -> Const Any s’
04:30 <lambdabot> Expected type: Getting Any s a0
04:31 <iqubic> Alright, that has the right type.
04:31 <jle`> > anyOf traverse (== 1) (Scale 1 3)
04:31 <lambdabot> True
04:31 soLucien joined
04:31 <jle`> but the way i was hinting to was:
04:31 <jle`> reading the documentation for anyOf
04:31 <glguy> anyOf only needs a Fold :)
04:31 <iqubic> Why do you have to use traverse there???
04:31 <jle`> http://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Fold.html#v:anyOf
04:31 <jle`> iqubic: anyOf's first argument is the Fold/Traversal
04:31 <jle`> same for toListOf
04:32 <jle`> same for 'over'
04:32 esph joined
04:32 <jle`> same for 'view'
04:32 <jle`> same for 'set', etc.
04:32 <iqubic> No, the first argument is the boolean function.
04:32 <iqubic> :t anyOf
04:32 <lambdabot> Getting Any s a -> (a -> Bool) -> s -> Bool
04:32 <jle`> pretty much the same for any function in lens that uses lenses/traversals/folds/prisms, etc.
04:32 <iqubic> Okay, I'm wrong.
04:33 <jle`> it's the same as over, view, set, toListOf, etc.
04:33 wroathe joined
04:33 mstan joined
04:33 <mstan> Anyone here?
04:34 <iqubic> :t each
04:34 <lambdabot> (Applicative f, Each s t a b) => (a -> f b) -> s -> f t
04:34 <jle`> each is a traversal
04:34 <jle`> well, for instances of Each
04:35 <jle`> just like how 'traverse' is a traversal, for instances of Traversable
04:35 <sophiag> can anyone take a look at my weak attempt to refactor some gnarly types?
04:35 <iqubic> I think that I don't need a traversal here.
04:36 <sophiag> here's a version that compiles, but i'm having trouble debugging: http://lpaste.net/354629
04:36 <jle`> iqubic: it depends on what you want to do, of course
04:36 <sophiag> and here's the new way i'm trying to structure it: http://lpaste.net/354632
04:37 indi_ joined
04:40 wroathe joined
04:42 takle joined
04:43 tyler569 joined
04:43 hexfive joined
04:45 <jle`> sophiag: what's the issue?
04:46 Xanather joined
04:47 <sophiag> well, if you look at the first paste you'll see two (actually there's a third, but let's ignore that) adts that both wrap each other and additionally the first just consists of list types of the second
04:48 <sophiag> it's making the code rather spaghetti-ish as i try to debug it
04:48 <sophiag> it was suggested i use a type variable in order to consolidate those two while still preventing heterogenous lists, which is what i'm trying in the new version of it
04:49 <sophiag> but having a lot of trouble...especially when wanting to define those homogenous list types
04:49 angelds joined
04:49 <sophiag> or moreso, pattern match for them
04:49 <sophiag> and i've resorted to existentials for my two record types as well
04:50 <sophiag> so i'm not sure whether it's a good idea to refactor this wasy and i just need to figure these things out (i think likely) or not
04:50 <sophiag> oh, the first paste does show the operational problems at the bottom as well
04:51 blender joined
04:52 <sophiag> does this make sense? it's a nearly finished dsl yet i'm spending sooo much time trying to debug the last bit, getting what should be really simple functions to work by contorting the type system and becoming quite frustrated
04:59 bjz joined
05:00 darjeeling_ joined
05:01 <sophiag> jle`: did i overwhelm you? :)
05:06 ublubu joined
05:07 mac10688 joined
05:08 Rodya_ joined
05:08 sleffy joined
05:12 geekosaur joined
05:13 ali_bush joined
05:13 ali_bush joined
05:15 bhiliyam joined
05:20 SimpleL joined
05:21 forgottenone joined
05:22 a3Dman joined
05:24 tmtwd joined
05:28 takle joined
05:29 <iqubic> I can't see any reason why anyone would want to use a traversal over a foldable instance with mapped
05:29 <iqubic> No reason at all.
05:29 forgottenone joined
05:30 <iqubic> Can someone enlighten me?
05:30 osa1 joined
05:30 osa1 joined
05:31 <jle`> sophiag: was just feeding you questions to help people help you :)
05:31 <jle`> iqubic: what is a 'foldable instance with mapped' ?
05:31 <iqubic> I'm not sure.
05:31 <iqubic> What I mean is, why have a full blown traversal instance when all you need is mapped?
05:31 <jle`> well, one reason to use a traversal ove a 'foldable instance with mapped' is that a traversal is a real thing
05:32 <jle`> by 'traversal instance', do you mean a traversal?
05:32 <iqubic> Yes.
05:32 systemfault joined
05:32 <iqubic> I mean something that is an instance of traversal.
05:32 <jle`> i explained earlier that mapped can't be used with things that expects folds
05:32 <jle`> 'instance of traversal', what is that?
05:32 <iqubic> I know that.
05:32 <jle`> so, there is your reason
05:33 <iqubic> jle`: instance Traversal Scale a where...
05:33 <iqubic> But that's not how that works, is it?
05:33 <jle`> what typeclass is that?
05:33 <jle`> there is no Traversal typeclass that is commonly used
05:33 <iqubic> Are traversals not a typeclass???
05:33 <jle`> no
05:33 <iqubic> I thought they were.
05:33 <jle`> Traversable is a typclass
05:34 <jle`> but traversals are just things/normal values
05:34 <iqubic> What does Traversable do
05:34 <iqubic> ?
05:34 <jle`> Traversable provides a traversal for * -> *-kinded things
05:34 <jle`> a "canonical" traversal
05:34 <iqubic> I see.
05:35 <iqubic> So why would anyone use any of the functions in the traversal box every, when you have over and modify?
05:35 <iqubic> *ever
05:35 <jle`> over can't do everything
05:35 <iqubic> What can't it do?
05:35 <iqubic> I know it can't do to list of.
05:35 <jle`> literally anything besides applying an (a -> b) function
05:36 <iqubic> Wait, over can't sequence a bunch of IO actions?
05:36 <jle`> so it literally can do pretty much nothing except map an (a -> b)
05:36 <iqubic> Oh. I see.
05:36 <jle`> all it can do is map a function
05:36 <iqubic> That's pretty restricted?
05:36 <jle`> well, it depends on what you consider useful things
05:37 <jle`> but it literally only has one function, heh
05:37 <jle`> 'restricted' is a vague word i guess, so you have to clarify what you mean
05:37 jgt1 joined
05:38 <iqubic> What if I want to take a travesal over a list of IO () and do all the actions?
05:38 <iqubic> Or just sequence a bunch of monadic actions all in a row?
05:38 <jle`> that's just sequence :: [IO ()] -> IO ()
05:38 <jle`> which is sequenceOf traverse
05:38 <iqubic> jle`: Does that require a travesal?
05:38 <jle`> :t sequenceOf traverse
05:38 <lambdabot> (Monad m, Traversable t) => t (m b) -> m (t b)
05:38 <jle`> it requires a Fold
05:38 <jle`> which all Traversal's are
05:39 <iqubic> How can you ahve a fold that is not a traversal?
05:39 <jle`> literally anything that isn't "map a function over this thing" can't be done by 'over', heh
05:39 <glguy> The one that needs a Fold is sequenceOf_
05:39 <ertes> is there a way to use generalised newtype deriving for Show? i would like to inherit the same instance
05:39 <jle`> ah yeah, sorry, sequence_ :: [IO ()] -> IO (), and sequenceOf_ traverse :: [IO ()] -> IO ()
05:39 <iqubic> How can you have a fold that's not a traversal?
05:39 <jle`> well, you can write one
05:40 <iqubic> How so?
05:40 <iqubic> What is the minimal complete definition of a fold?
05:40 <jle`> lens provies 'folded', which gives you a Fold for every Foldable instance
05:40 <jle`> but, the difeference between Foldable and Traversable is interesting
05:40 <glguy> ertes: There's stuff coming in GHC 8.2 to allow you to pick your 'deriving' strategy
05:40 <glguy> Maybe that will help
05:40 <jle`> Foldable's minimum interface is a "toList" function
05:41 <iqubic> What does toList do?
05:41 <jle`> Foldable lets you iterate through all the items in an object
05:41 <jle`> iqubic: i'll give you one guess :)
05:41 AX3L joined
05:41 <iqubic> jle` Does it take an items objects and put them in a list?
05:41 <jle`> what Traversable adds to Foldable is that it lets you *reconstruct* the original structure, with the results of your traversing function
05:42 <iqubic> What does that mean?
05:42 <ertes> glguy: nice… no way to achieve that with GHC 8.0 though, i take it
05:42 <jle`> iqubic: do you know about 'Map'?
05:42 <jle`> key-value pairs
05:42 <iqubic> I do.
05:42 <glguy> ertes: I'm not ready to say "no way" but I don't know of a way
05:42 <iqubic> I know about key-value pairs.
05:42 <jle`> 'Map k' has a Foldable instance, which lets you sequence all of the actions it contains
05:42 <jle`> but you can't "collect" the results back into a new Map
05:42 <jle`> you lose the original map's structure forever
05:43 <jle`> mapM_ :: (a -> f b) -> Map k a -> f ()
05:43 <jchia_1> When defining some function that returns an IO a, is it always better to define it in more general terms with constraint MonadIO m returning m a instead of returning IO a? When is it not a good idea?
05:43 <jle`> but, Traversable lets you reconstruct a new map with the results of your traversing function
05:43 <jle`> mapM :: (a -> f b) -> Map k a -> f (Map k b)
05:43 <jle`> what mapM does for Map k is it sequences the 'a -> f b' function for all the items in the map, and then collects the results
05:43 <iqubic> Is mapM provided by lens?
05:44 <jle`> mapM is a part of the Traversable typeclass
05:44 <ertes> jle`: side note: the primitive of Foldable is foldMap (or fold), not toList
05:44 <jle`> it's also called 'traverse'
05:44 <jle`> they are synonyms more or less
05:44 <glguy> jchia_1: In general it's best not to do that
05:44 <iqubic> Well, alrigt.
05:44 <jle`> traverse :: (a -> f b) -> Map k a -> f (Map k b)
05:44 <jle`> traverse_ :: (a -> f b) -> Map k a -> f ()
05:44 <jle`> *traverse_ is from Foldable
05:44 <iqubic> And a lens lets you look at just one item in your data, right?
05:44 <glguy> perhaps in some specific case it'll be more locally useful to do so, but if you're exposing functions for someone else to use it's better to just provide IO types
05:45 <jle`> yeah. a lens is a traversal over exactly one item
05:45 <jchia_1> glguy: Why? Doesn't it allow for more reuse?
05:45 <glguy> It makes things more complicated and slower
05:45 meba joined
05:45 <ertes> glguy, jchia_1: i must say, i do find libraries that abstract over MonadIO to be more convenient to work with
05:45 <iqubic> jle`: After that you have isos and prisms.
05:45 <jle`> iqubic: the difference is pretty much that traverse/Traversable preserves the structure of the thing you are traversing
05:45 <iqubic> I see
05:46 <iqubic> How do isos and prisms work?
05:46 <iqubic> Do you have time to explain that?
05:46 <glguy> I find it quite unnecessary
05:46 <jchia_1> glguy: I now find myself having to edit existing code to change them to use MonadIO instead of IO because the users now use a MonadIO that's not IO.
05:46 <glguy> the user can just use liftIO if needed
05:46 <jchia_1> glguy: That seems like a lot of boilerplate to me.
05:46 <glguy> or whatever new class they've made to lift IO
05:46 <ertes> jchia_1: using IO is fine… it also eliminates the discrepancy between returning IO and taking IO
05:47 <iqubic> How do prisms and isos work?
05:47 juhp1 joined
05:47 <glguy> jchia_1: I mean, I don't have to use any of your code, so do whatever you want :)
05:47 <iqubic> I want to understand those
05:47 <glguy> I'm just answering the question
05:47 <jchia_1> glguy: Just getting different points of view.
05:47 <ertes> jchia_1: for example you can't fully abstract something like 'catch' or 'withFile' without something like monad-control
05:47 takle joined
05:47 <jle`> iqubic: if you can read the chart, you can see what prisms and isos can do
05:48 <iqubic> How can you have a Getter that is not a Lens?
05:48 <iqubic> Or a Setter that isn't a Traversal?
05:48 <jle`> in the box, the first section are ways to "construct" the thing
05:48 <jle`> so 'to' is a way to construct a Getter
05:48 <jle`> to :: (s -> a) -> Getter s a
05:48 <iqubic> Alright.
05:49 <iqubic> How does that differ from a lens?
05:49 <jle`> 'to f' is a getter, but not a lens
05:49 <jle`> well, lenses can modify things
05:49 <jle`> getters can only extract things
05:49 <iqubic> And setters can only place things back in?
05:49 <ertes> iqubic: you might encounter Getter when things are hidden and not supposed to be modified by the user… however, in that case don't write a Getter, but just a function
05:49 <iqubic> Alright.
05:49 thunderrd_ joined
05:49 <jle`> iqubic: look at the box for Setter
05:50 <jle`> to see what a setter can do
05:50 <iqubic> Now can someone explain isos and lenses.
05:50 <iqubic> ???
05:50 <iqubic> I can't understand prisms or isos.
05:50 <jle`> prisms can be used as Reviews, Traversals, Folds, and Setters
05:51 <iqubic> SUre.
05:51 <iqubic> I get tht.
05:51 <jchia_1> What does it mean when GHC gives the warning "No explicit implementation for ..." with -Wmissing-methods. Does it mean that I end up with no implementation and may get a run-time error or does it mean that I end up with the default implementation provided by the typeclass?
05:51 <jle`> so you understand traversals, folds, and setters already
05:51 <jle`> you understand 75% of prisms :)
05:51 <iqubic> Yes I do.
05:51 <iqubic> What is a review?
05:51 <ertes> jchia_1: GHC does not warn about default implementations
05:51 <ertes> jchia_1: so it means there is something wrong
05:51 <jle`> iqubic: Review lets you construct a structure given one of its parts
05:52 <jle`> it's like the opposite of Getter, kinda
05:52 <jchia_1> ertes: That means I may get a run-time error when the missing function gets called?
05:52 leah2 joined
05:52 <ertes> jchia_1: yeah
05:52 <iqubic> jle`: Isn't that what a lens does?
05:52 <jle`> iqubic: you can't do that with a lens
05:52 <jle`> for example, a lens that gets the first item in a tuple
05:52 <jle`> you can't create a tuple from just the first item
05:52 <ertes> iqubic: _Just is a prism… it's an up-to-1 traversal with extra information in order to *construct* a Just
05:52 <ertes> > _Just # 5
05:52 <jle`> _1 gives you a (a, b) -> a, but it doesn't get you an a -> (a, b)
05:52 <lambdabot> Just 5
05:53 <iqubic> You can't just pull the second element out of thin air though.
05:53 <jle`> exactly
05:53 <iqubic> How does that work?
05:53 <jle`> that's why _1 is not a prism
05:53 <jle`> that was my point :)
05:53 <iqubic> So what is an example of a valid prism?
05:53 <iqubic> Why is _just a prism?
05:53 <jle`> or well, what i meant to say is, that's why _1 is not a Review
05:54 <jle`> iqubic: _Just is a prism that looks at the value that a Maybe contains
05:54 <jle`> and, well, you can see that if you are given an 'a', you can create a 'Maybe a'
05:54 <ertes> Review may not be the best name =)
05:54 <iqubic> sure. But a Maybe might have 0 values.
05:54 <iqubic> Nothing has no values.
05:54 <jle`> yes, so it's not a lens
05:54 <jle`> it's a Traversal
05:55 <jle`> traversals can have 0, 1, or a buncha values.
05:55 <iqubic> Right. But you can still construct the original data if you want.
05:55 spatial joined
05:55 thunderrd__ joined
05:55 <jle`> yeah, so _Just is a Traversal + Review
05:55 <jle`> you can "traverse" the values inside the Maybe, if there are any
05:55 <spatial> Is there a haskell library equivalent to Python's matplotlib ?
05:55 <jle`> and, as a Review, you can have an a -> Maybe a
05:55 <iqubic> Are there other Reviews I need to know about?
05:56 <iqubic> Can you give me another Review?
05:56 <ertes> > _Left # 5
05:56 <lambdabot> Left 5
05:56 <jle`> there aren't many things that are "only" Reviews
05:56 <jle`> but you can make an arbitrary one with 'unto'
05:56 <iqubic> Alright, so give me some prisms then.
05:56 <jle`> but, there are several useful prisms
05:56 <jle`> _Left, _Right, _Just are examples
05:56 <jle`> _Left is a prism into the "left" item in an Either e a
05:57 <iqubic> Can you have a prism into the first element of a list?
05:57 <iqubic> Because [] has no first element.
05:57 <iqubic> How come a prism is not a lens?
05:58 <ertes> you can have a prism that corresponds to the (:) constructor
05:58 <jle`> iqubic: lenses are traversals with exactly one item
05:58 <jle`> iqubic: but prisms might have 0 items
05:58 <jle`> as we have seen with _Just and _Left and _Right
05:58 <ertes> a prism can be a lens, but generally it's not
05:58 <iqubic> ertes, how would the prism of (:) work?
05:58 <jle`> one of my favorite prisms is hex
05:59 <iqubic> How does hex work?
05:59 <ertes> :t unto
05:59 <lambdabot> (Functor f, Bifunctor p, Profunctor p) => (b -> t) -> Optic p f s t a b
05:59 <jle`> hex is a prism into the integer encded as a hax value in a string
05:59 <jle`> > over hex (*2) "a7eb3"
05:59 <lambdabot> "14fd66"
05:59 <jle`> > over hex (`div` 2) "a7eb3"
05:59 <lambdabot> "53f59"
05:59 <iqubic> And a given string is either a hex number or not.
05:59 <jle`> yeah, a string might not contain a number
05:59 <ertes> > unto (:) # (1, [2,3,4])
05:59 <lambdabot> <[(Integer,[Integer])] -> [(Integer,[Integer])]>
06:00 <jle`> > review hex "a7eb3"
06:00 <lambdabot> error:
06:00 <lambdabot> • No instance for (Integral [Char]) arising from a use of ‘hex’
06:00 <lambdabot> • In the first argument of ‘review’, namely ‘hex’
06:00 <jle`> aw
06:00 bhiliyam joined
06:00 <jle`> > preview hex "a7eb3"
06:00 <lambdabot> Just 687795
06:00 <ertes> > unto (uncurry (:)) # (1, [2,3,4])
06:00 <lambdabot> [1,2,3,4]
06:00 <jle`> > "a7eb3" ^.. hex
06:00 <lambdabot> [687795]
06:00 <iqubic> "QQQ" ^.. hex
06:00 <ertes> (but that one is only a Review)
06:00 <iqubic> > "QQQ" ^.. hex
06:00 <lambdabot> []
06:01 <iqubic> Why did I get that result?
06:01 <iqubic> Should I get Nothing?
06:01 <jle`> iqubic: well, "QQQ" contains no hex integer
06:01 <jle`> ^.. returns a list
06:01 <jle`> preview returns Just/Maybe
06:01 <iqubic> > preview hex "QQQ"
06:01 <lambdabot> Nothing
06:01 <iqubic> > view hex 100
06:01 <jle`> preview is like toListOf + listToMaybe
06:01 <lambdabot> error:
06:01 <lambdabot> • Could not deduce (Num String) arising from the literal ‘100’
06:01 <lambdabot> from the context: (Monoid t, Integral t)
06:02 <jle`> see, you can't use view with hex, because view only works for lenses
06:02 <iqubic> > review hex 100
06:02 <lambdabot> "64"
06:02 <jle`> remember, review "creates" the structure from the part
06:02 <iqubic> Is there an ifix form of review?
06:02 <jle`> yes, ertes has been using it
06:02 <iqubic> and one for preview too?
06:02 splanch joined
06:02 <jle`> ^?
06:03 <iqubic> Now, let's talk about isos.
06:03 <iqubic> I think I want to learn about them now.
06:03 <iqubic> If you still have time and energy to explain them.
06:03 <jle`> you already know enough to understand iso's
06:03 <jle`> just from the chart
06:03 <jle`> iso's are prism + lens
06:04 <iqubic> How can you have something that acts like both a prism and a lens, at the same time?
06:04 <jle`> so they are also review, traversal, getting, fold, etc.
06:04 simukis__ joined
06:04 <jle`> well, what did we see before that prevented a prism from being a lens?
06:04 <jle`> a prism might have 0 values
06:04 <iqubic> Right.
06:05 kamyar joined
06:05 <jle`> so maybe you can think of an iso as being a prism that always has exactly 1 value
06:05 <iqubic> So, how does an iso get around that?
06:05 <jle`> where preview is always Just
06:05 <kamyar> Hey anyone please answer my wuestion
06:05 <kamyar> question
06:05 <iqubic> Can I have an example of an iso?
06:05 <iqubic> Do you have a good one to show me?
06:05 <kamyar> I just want to use MessagePack
06:05 <kamyar> on GHC 8.0.2
06:05 <kamyar> I have to use data-messagepack
06:06 <kamyar> which is a fork
06:06 <kamyar> How can I serialize data using messagepack?
06:06 <jle`> iqubic: if two types are considered "identical" or isomorphic ot each other, then you can make an iso out of them
06:06 <iqubic> Can you give me an example of that?
06:06 <iqubic> I'm not understanding that at all.
06:07 <jle`> there's an isomorphismb etween (a, b) and (b, a)
06:07 <iqubic> Right.
06:07 <iqubic> Now how do I make an iso out of that?
06:07 <jle`> that's 'swapped'
06:07 <kamyar> Hey no one can answer my question?
06:07 <jle`> or well, you can make an iso if you can provide the "to" and "from" functions
06:07 <jle`> but lens already gives you 'swapped'
06:07 <jle`> > review swapped ('a',3)
06:07 <lambdabot> (3,'a')
06:07 <jle`> > view swapped (3, 'a')
06:07 <lambdabot> ('a',3)
06:08 <jle`> one of the more famous iso's is non
06:09 <jle`> oh, the most famous iso is 'id', of course
06:09 <jle`> which says that every type is isomorphic to itself
06:09 <jle`> the "thing inside" is just the thing itself
06:09 <jle`> > view id "hello"
06:09 SimpleL joined
06:10 <lambdabot> "hello"
06:10 <jle`> > review id "hello"
06:10 <lambdabot> "hello"
06:10 <jle`> > over id (*2) 10
06:10 <lambdabot> 20
06:10 <iqubic> Let me guess:
06:11 <iqubic> if _iso_ is an iso then review _iso_ (view _iso_ x) = x
06:11 <iqubic> sorry bout that.
06:11 <jle`> yes :)
06:11 <iqubic> If I apply review and then view to an iso, I get the same value.
06:12 <iqubic> review iso (view iso) = id
06:12 <iqubic> for any iso
06:12 <jle`> mhm
06:12 <jle`> view i . review i = review i . view i = id
06:12 soniku joined
06:12 Hail_Spacecake joined
06:12 blender joined
06:12 <iqubic> why aren't we using preveiw here?
06:13 <iqubic> *preview?
06:13 <jle`> preview returns a Maybe, remember
06:13 <jle`> for an iso, preview will always return Just
06:13 <Hail_Spacecake> is there a concise way to say "is a equal to anything in this list"? where a and hte list all implement Eq?
06:13 <Hail_Spacecake> basically I want to do if a == a' || a == a'' || a == a''' ,etc.
06:13 <Hail_Spacecake> in a more concise way
06:13 <iqubic> :t anyMatch
06:13 <lambdabot> error: Variable not in scope: anyMatch
06:13 <iqubic> :t any
06:14 <lambdabot> Foldable t => (a -> Bool) -> t a -> Bool
06:14 <monochrom> elem
06:14 <jle`> Hail_Spacecake: yu want 'elem'
06:14 <iqubic> Hail_Spacecake: any (== a) [xs]
06:14 takle joined
06:14 <Hail_Spacecake> ah, elem
06:14 <kamyar> How can I read Haddick for a package?
06:14 <iqubic> I think that's what you want.
06:14 <Hail_Spacecake> okay, thanks
06:14 <kamyar> Haddock
06:14 <jle`> > 'e' `elem' "hello"
06:14 <lambdabot> <hint>:1:12: error: parse error on input ‘"’
06:14 <jle`> > 'e' `elem` "hello"
06:14 <lambdabot> True
06:14 <jle`> > 'x' `elem` "hello"
06:14 <kamyar> how to get Haddocks?
06:14 <lambdabot> False
06:14 <iqubic> Does my function work?
06:15 <iqubic> any (== a) [xs]
06:15 <monochrom> No.
06:15 <iqubic> why not?
06:15 <monochrom> Check its type.
06:15 <kamyar> Hey please
06:15 <kamyar> How can I use Haddock?
06:15 <iqubic> :t any (== a) [xs]
06:15 <lambdabot> error:
06:15 <lambdabot> • Variable not in scope: xs :: Expr
06:15 <lambdabot> • Perhaps you meant one of these:
06:15 <kamyar> I just want to read some package docs
06:15 <jle`> kamyar: if it's on hackage, you can look there
06:15 <iqubic> :t any (== a) []
06:15 <lambdabot> Bool
06:16 <jle`> iqubic: maybe you mean any (== a) xs, instead of [xs]
06:16 <iqubic> Yeah, I think so.
06:16 <kamyar> jle`: On website? I cant find any! see msgpack package
06:16 <iqubic> :t any (== a) xs
06:16 <lambdabot> error:
06:16 <lambdabot> • Variable not in scope: xs :: [Expr]
06:16 <lambdabot> • Perhaps you meant one of these:
06:16 <jle`> @hackage mspack
06:16 <lambdabot> http://hackage.haskell.org/package/mspack
06:17 <jle`> @hackage msgpack
06:17 <lambdabot> http://hackage.haskell.org/package/msgpack
06:17 xall_ joined
06:17 edvorg joined
06:17 <iqubic> jle`: What's the difference between an iso and an equality?
06:17 <jle`> hackage should also have search functionality too
06:18 <jle`> iqubic: the only equality is 'id'
06:18 <iqubic> What does that mean?
06:18 <jle`> id is an Iso
06:19 <iqubic> why have the equality data then?
06:19 <jle`> and a Lens, and a Fold, and a Prism, and a Traversal
06:19 <jle`> none of these are data types, remember
06:19 <iqubic> jle`: how does id act like a prism?
06:19 <jle`> like i said earlier, its "part" is the thing itself
06:19 <iqubic> jle`: What are they then, if not data types?
06:19 <jle`> so id is a prism into the entire structure
06:19 <jle`> iqubic: they're just normal functions
06:19 <jle`> everyday haskell functions
06:19 <jle`> they're "families"
06:20 <jle`> implemented as type synonyms
06:20 connrs joined
06:20 <jle`> a Traversal is any function that fits the pattern Applicative f => (a -> f b) -> (s -> f t), for some a, b, s, and t
06:20 <iqubic> Alright then.
06:20 <jle`> (+ some laws)
06:20 <iqubic> Well I understand this library a lot better than I used to.
06:20 <jle`> id is a prism into the entire structure
06:21 <jle`> > review id 10
06:21 <lambdabot> 10
06:21 <jle`> > view id 10
06:21 <iqubic> Thanks for helping.
06:21 <lambdabot> 10
06:21 <jle`> no problem!
06:21 <Xnuk> @hackage msgpack https://www.stackage.org/nightly/package/data-msgpack
06:21 <lambdabot> http://hackage.haskell.org/package/msgpack https://www.stackage.org/nightly/package/data-msgpack
06:21 <iqubic> > previw id 10
06:21 <lambdabot> error:
06:21 <lambdabot> • Variable not in scope: previw :: (a0 -> a0) -> Integer -> t
06:21 <lambdabot> • Perhaps you meant one of these:
06:21 <iqubic> > preview id 10
06:21 <lambdabot> Just 10
06:21 <iqubic> wait, for id, preview = Just
06:22 <jle`> yes, preview "gets" the thing inside, and returns Just if there is anything inside, and Nothing if not
06:22 <jle`> for id, the thing inside is the thing itself
06:22 <jle`> so it will always just return Just the thing itself
06:23 mzf joined
06:23 <iqubic> I don't understand the type signature for prism.
06:24 <iqubic> Can you explain why those Eithers are hanging out there
06:25 <iqubic> prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b
06:25 <iqubic> How does that work>
06:25 <iqubic> ??
06:26 mkoenig joined
06:26 <iqubic> And what is the type synonym for Prism s t a b?
06:29 geekosaur joined
06:30 xmonader2 joined
06:33 <iqubic> Oh, I see.
06:34 <iqubic> to construct Prism' you use: (s -> a) -> (a -> Maybe s) -> Prism
06:34 iomonad joined
06:35 superKiller joined
06:36 splanch joined
06:37 sophiag joined
06:40 bendricklamar joined
06:40 indi_ joined
06:41 peterbecich joined
06:43 govg joined
06:43 connrs joined
06:46 insitu joined
06:48 peterbec` joined
06:49 angelds joined
06:51 darjeeling_ joined
06:51 angelds joined
06:52 connrs joined
06:52 boombanana joined
06:54 jmnoz joined
06:55 free_beard joined
07:02 takuan joined
07:02 insitu joined
07:04 angelds joined
07:05 Nikotiini joined
07:05 carbolymer joined
07:08 k_ joined
07:09 Denthir joined
07:10 Rodya_ joined
07:13 splanch joined
07:13 soniku joined
07:14 blender joined
07:21 orbifx joined
07:26 meba joined
07:26 blender joined
07:28 zenware joined
07:30 darkSeid_ left
07:33 connrs joined
07:35 codesoup joined
07:37 kamyar joined
07:37 <kamyar> hello all
07:37 meba joined
07:37 <kamyar> PLease help me with some haskell code
07:40 <tsahyt> kamyar: just state your question. and please use a pastebin for code
07:40 <kamyar> tsahyt: I did it 3 times, with no answer
07:40 <kamyar> tsahyt: I a trying to fix it myself, wait plz
07:40 takle joined
07:46 <kamyar> I just want to serialize something using MessagePack
07:46 jopairTheBear joined
07:46 <kamyar> Since I am using GHC 8, I have to use data-msgpack
07:48 aib joined
07:49 bhiliyam joined
07:50 <pavonia> kamyar: What have you tried? What errors did you get?
07:51 <kamyar> pavonia: At last, I succeeded serializing using msgpack, using GHC Generics
07:51 <dysfun> what is the correct 'modern haskell' form of EitherT A (ReaderT B (StateT C IO)) ? I've got MonadError A (MonadReader B (MonadState C)) but ghc isn't happy
07:52 <kamyar> pavonia: But there is another problem: I am trying to save the result into the redis. It is ok. But I want to call the function within scotty web action.
07:52 <kamyar> pavonia: let me paste the code
07:53 <pavonia> dysfun: These Monad*s are typeclasses, no?
07:53 <dysfun> it's not clear from the material i'm using
07:54 <dysfun> how do i stack them?
07:54 <dysfun> do they just become constraints?
07:54 <kamyar> pavonia: Here is the code: https://pastebin.com/pVBz1mTJ
07:54 raichoo joined
07:55 mounty joined
07:55 takle joined
07:56 <pavonia> kamyar: I don't know about Redis, sorry
07:56 <pavonia> dysfun: What module are you using?
07:56 <dysfun> this is my own code. i'm just trying to tidy the code up
07:57 <pavonia> You wrote these monad transformers yourself?
07:57 <dysfun> oh, no, they're from mtl
07:57 <tsahyt> dysfun: (MonadError A m, MonadReader B m, MonadState C m) => ... -> m D?
07:58 <pavonia> So then yoe become constraints, yes
07:58 <pavonia> *they
07:58 jopairTheBear left
07:58 <dysfun> so i am writing an interpreter and the line i am trying to change is the type of the monad stack for the runtime of the interpreter
07:59 <dysfun> i know the underlying monad will be IO, and i know which monads should be stacked in the stack
07:59 <tsahyt> dysfun: can you post some code?
07:59 <tsahyt> in a pastebin that is
08:00 <dysfun> it's one line
08:00 <dysfun> type Runtime = EitherT Error (ReaderT Scope (StateT Context IO))
08:00 <dysfun> i was wondering what that looks like in 'modern' haskell
08:01 _main_ joined
08:01 <dysfun> i can use that as e.g. Runtime Int to return an Int
08:02 _main_ joined
08:02 <dysfun> and this works fine with the line as it is there
08:02 mounty joined
08:03 <tsahyt> that's the concrete transformer stack. that's okay as is. where typeclasses come into play is when you define functions working on that stack
08:03 <dysfun> okay, so keep on with this structure except for places where it's meant to be generic?
08:03 <tsahyt> e.g. you'd have a foo :: (MonadError Error m) => Foo -> m Bar
08:03 <tsahyt> which would still run fine in your Runtime stack
08:04 <dysfun> ok
08:04 <tsahyt> but the type signature denotes that you only ever need some monad that can handle errors. that guarantees that you e.g. never touch the state part
08:04 __main__ joined
08:04 <dysfun> but it will fill in the missing lifts conveniently?
08:04 <tsahyt> yes
08:04 <dysfun> neat
08:04 <dysfun> which leads to my second question
08:05 <tsahyt> except for when you have MonadIO m => m a. to use an IO function there you still need liftIO
08:05 <tsahyt> of course if you have a function that returns a MonadIO m => m a, then you don't. this is only for functions returning IO a.
08:05 <tsahyt> :t liftIO
08:05 <lambdabot> MonadIO m => IO a -> m a
08:05 <dysfun> i want to execute a Runtime m in the context of a changed Scope from the Reader, but GHC isn't happy because of the other things in the stack
08:06 <tsahyt> :t local
08:06 <lambdabot> MonadReader r m => (r -> r) -> m a -> m a
08:06 <tsahyt> how are you trying to execute this?
08:06 <dysfun> https://gist.github.com/jjl/32f98c12b3dbd5cb1456bf71bcb3699b
08:07 <dysfun> i have been playing around trying to make that work and i'm out of ideas
08:07 <* dysfun> has tried lift, etc.
08:08 <tsahyt> so basically you want to call a function in the same transformer stack but with a changed reader environment?
08:08 <dysfun> exactly
08:08 <tsahyt> local should work
08:08 <* dysfun> tries
08:08 <tsahyt> at least I think it should, I've never had that use case. my readers usually only carry config stuff etc
08:09 Wedamm1 joined
08:10 <dysfun> holy crap, it just worked
08:10 splanch joined
08:10 <dysfun> thanks! :)
08:10 biglambda joined
08:11 deveshp joined
08:14 forgottenone joined
08:14 yellowj joined
08:15 systemfault joined
08:17 lep-delete joined
08:17 connrs joined
08:21 cfricke joined
08:22 wei2912 joined
08:23 mmn80 joined
08:24 revprez_atlanta joined
08:24 thc202 joined
08:25 rockfordal joined
08:27 elementar joined
08:28 connrs joined
08:28 blender joined
08:31 t0by joined
08:32 jshjsh joined
08:33 chbatey joined
08:33 <elementar> a question to people familiar with Attoparsec: why does the following parse fail?
08:33 <elementar> parseOnly ("foo" *> many1 anyChar <* "bar") "fooxxxbar"
08:34 SimpleL joined
08:35 <* dysfun> doesn't recall attoparsec accepting strings as parsers
08:35 <dysfun> don't you need a function for that?
08:36 <dysfun> it's called "string"
08:36 <dysfun> https://hackage.haskell.org/package/attoparsec-
08:37 Icewing joined
08:37 <elementar> dysfun: oh, I'm using OverloadedStrings
08:37 <* dysfun> still doesn't recall attoparsec accepting strings as parsers
08:37 <elementar> by "fails" I mean parsing failure, everything typecheks
08:38 <sophiag> dysfun :)
08:38 <dysfun> oh god, are you haskelling now sophiag ?
08:38 <sophiag> yup
08:38 gawen joined
08:38 <dysfun> elementar: i don't remember in attoparsec specifically, but if i did that in megaparsec, many1 would eat all the chars
08:39 <elementar> dysfun: using "string" has the same result (failure)
08:39 <elementar> dysfun: but isn't Attoparsec supposed to always backtrack?
08:40 <dysfun> "always" is a rather strong statement
08:40 <dysfun> many1 hasn't actually failed
08:40 fnurglewitz joined
08:40 Yuras joined
08:40 blender joined
08:41 <dysfun> manyTill would be my suggestion anyway
08:41 <dysfun> https://hackage.haskell.org/package/attoparsec-
08:43 tomboy64 joined
08:47 <tsahyt> is there any research on extracting test cases by inspecting functional code? e.g. something coverage based for example.
08:48 zcourts_ joined
08:48 mounty joined
08:50 zcourts__ joined
08:51 Berra joined
08:51 jomg joined
08:53 takle joined
08:59 Beginner_ joined
09:00 pera joined
09:00 oisdk joined
09:01 mounty joined
09:03 <Beginner_> Hi, I get "Failed to load interface.." error when I :load the module. Only when not in base, e.g. I put ad (auto differentiation stuff) in the .cabal build depends. Stack build Ok. What's going wrong please?
09:03 tomboy64 joined
09:04 fractalsea joined
09:06 fkurkowski joined
09:07 raichoo joined
09:08 ltielen joined
09:08 ccomb joined
09:09 hexfive joined
09:09 magneticduck joined
09:11 TCZ joined
09:12 Rodya_ joined
09:13 iomonad joined
09:13 soniku joined
09:17 ixxie joined
09:17 jbracker_ joined
09:17 tomboy64 joined
09:18 markus1189 joined
09:18 markus1199 joined
09:20 bhiliyam joined
09:25 <Beginner_> My Q is not right for here - will try elsewhere.
09:25 aib joined
09:26 f-a joined
09:27 dcoutts_ joined
09:30 troydm joined
09:32 shwouchk joined
09:33 doomlord joined
09:33 bhiliyam joined
09:33 azahi joined
09:34 catsup joined
09:35 catsup joined
09:38 meba joined
09:40 bjz_ joined
09:41 dc0de joined
09:42 fmmarques joined
09:45 takle joined
09:46 Swizec joined
09:47 RegEchse joined
09:48 Vooray joined
09:49 vydd joined
09:49 jchia joined
09:55 Avogadro joined
09:55 frofru joined
09:56 <frofru> hey there, I have a pipe question for you guys: http://lpaste.net/2888913544386969600 GHC complains that Couldn't match type ‘BS.ByteString’ with 'Data.ByteString.Lazy.Internal.ByteString'
09:57 f-a left
09:57 <frofru> any idea why?
09:59 Vooray left
10:00 leah2 joined
10:01 insitu joined
10:01 Itkovian joined
10:03 angelds joined
10:04 <tsahyt> frofru: presumably, you're trying to use strict bytestrings, but the library wants to use lazy ones
10:05 <tsahyt> btw, fromJust is already defined in Data.Maybe
10:05 augur joined
10:06 Gurkenglas joined
10:07 <frofru> tsahyt: I forgot to mention that if I switch to lazy BS, it complains too: import qualified Data.ByteString.Lazy as BS => Couldn't match type ‘Data.ByteString.Internal.ByteString’ with ‘BS.ByteString’
10:07 <frofru>
10:08 herr_jth joined
10:09 c0dehero joined
10:10 raid joined
10:11 <tsahyt> frofru: it seems like pipes-zlib gives you a producer for strict bytestrings, but aeson's decode accepts a lazy one
10:11 <tsahyt> try decodeStrict
10:12 Rodya_ joined
10:12 <frofru> tsahyt: ah, that was it! thanks!
10:14 alx741_ joined
10:14 orhan89 joined
10:14 netheranthem joined
10:14 soniku joined
10:15 SuperTux88 joined
10:15 Aruro joined
10:16 Kreest joined
10:17 ao1ei8 joined
10:17 meoblast001 joined
10:17 ao1ei8 left
10:18 kritzcreek_ joined
10:19 CurryWurst joined
10:21 be5invis joined
10:21 richi235 joined
10:23 Denthir joined
10:28 oisdk joined
10:29 JoshS joined
10:31 biglama joined
10:31 teggi joined
10:39 shane joined
10:40 epsilonhalbe joined
10:41 jchia joined
10:44 sepp2k joined
10:47 chbatey joined
10:49 augur joined
10:50 azahi joined
10:55 rmrfroot joined
10:56 blender joined
10:57 forgottenone joined
10:57 Aruro joined
10:57 inad922 joined
10:58 dddddd joined
11:00 leah2 joined
11:01 Dykam joined
11:02 fakenerd joined
11:02 Snircle joined
11:04 t7 joined
11:05 simukis__ joined
11:06 wildlander joined
11:07 xmonader3 joined
11:08 coot joined
11:10 oisdk joined
11:11 mzf joined
11:12 morphit joined
11:12 blender joined
11:13 xmonader2 joined
11:13 Rodya_ joined
11:15 soniku joined
11:16 simukis__ joined
11:16 Swizec joined
11:17 N0F4C3_47 joined
11:17 oisdk joined
11:18 fakenerd joined
11:27 whiteline joined
11:27 whiteline joined
11:29 dcoutts_ joined
11:30 karce joined
11:35 <AWizzArd> (>>=) is pronounced “bind”. Is there aso a name for (>>)?
11:36 <ij> How do I make stack show me the path of the executable?
11:37 shesek joined
11:37 mahdi joined
11:38 <tsahyt> AWizzArd: "then" or "sequence"
11:38 <tsahyt> source https://wiki.haskell.org/Pronunciation
11:39 epsilonhalbe left
11:39 mzf joined
11:39 <AWizzArd> tsahyt: ah right, good. Thx!
11:42 f-a joined
11:43 albertus1 joined
11:44 albertus1 joined
11:44 Sampuka joined
11:44 <f-a> I was looking for an extension to use distfix in my haskell project. Alas, there seems no such extension.
11:44 <f-a> is there a specific reason why it isn't so? Or just lack of someone implementing it?
11:47 nirvinm joined
11:49 twanvl joined
11:50 wei2912 joined
11:54 ompaul joined
11:54 nirvinm joined
11:55 binaryplease joined
11:55 binaryplease joined
11:58 richi235 joined
11:58 Aruro joined
11:58 bhiliyam joined
12:03 hylo joined
12:03 blender joined
12:03 JoelMcCracken joined
12:04 LAZAR joined
12:04 <LAZAR> What is better practise? Using $ or parentheses? I mostly see $ being used with print...
12:05 <f-a> matter of personal choice, LAZAR . I prefer parentheses as $ $ $ $ makes it less readable to me
12:06 soLucien joined
12:08 plutoniix joined
12:08 Deide joined
12:08 <AWizzArd> LAZAR: Coming from Clojure and Common Lisp there is some preferrence for parens, for me. However, for short examples I sometimes use a single $.
12:08 <dysfun> i think using a mixture is good
12:08 <LAZAR> f-a: yeah its a close call, print $ (2*) $ abs $ -5 vs print((2*)(abs(-5)))
12:08 edvorg joined
12:09 <LAZAR> if you purely use parens it starts looking like lisp
12:09 <AWizzArd> You would still have to use the prefix variant for operators tho.
12:10 <f-a> LAZAR: when I see something like `print $ (2*) $ abs $ -5 vs print((2*)(abs(-5)))` I know I need some lets or wheres
12:10 <rmrfroot> I like to mix $, paratheses and .
12:10 <rmrfroot> As much as possible
12:11 <LAZAR> f-a: can you refactor this example? im not quite familiar with the latter (i only used where in functions to remove redundancy yet)
12:11 <AWizzArd> f-a: I agree. Programs are written for human readers and it just is the case that also the computer must be able to read them.
12:12 <f-a> LAZAR: remember that function application has precedence over everything, too
12:12 <f-a> so
12:12 <f-a> > print $ 2* abs (-5) -- this will do
12:12 <lambdabot> <IO ()>
12:13 <f-a> 2 *, not 2*
12:14 blender joined
12:14 Rodya_ joined
12:14 LuckyRawApe joined
12:14 leah2 joined
12:14 <rmrfroot> haha, what about this version? isn't it lovely? `print . (*) 2 . abs $ -5`
12:15 <f-a> hehe
12:16 <rmrfroot> You know it bad when you have to put this disclaimer in your code: "Warning: do not look directly at this code, it may cause blindness"
12:16 bhiliyam joined
12:23 <Tuplanolla> It's the software equivalent of "do not look directly at the operational end of the device".
12:25 wroathe joined
12:26 revprez_atlanta joined
12:26 <troydm> I was always wondering why there is no search box for package on LTS Haskell web page because that is what mostly ppl do, they search for packages in LTS Haskell, that hoogle search box is totally useless there
12:32 bollu joined
12:32 <rmrfroot> Tuplanolla: haha
12:35 <LAZAR> Its just really weird that haskell allows function composition by no less than three different syntactic ways... (parens, $ and .)
12:35 <hpc> ($) and (.) aren't syntax
12:35 <hpc> also there's waaaaaay more than just those ;)
12:36 <hpc> @src ($)
12:36 <lambdabot> f $ x = f x
12:36 <hpc> @src (.)
12:36 <lambdabot> (f . g) x = f (g x)
12:36 <Tuplanolla> :t negate .: (*)
12:36 <lambdabot> Num b => b -> b -> b
12:37 <Tuplanolla> :t id &&& negate
12:37 <lambdabot> Num b => b -> (b, b)
12:37 <Tuplanolla> Have some more, LAZAR.
12:38 Prutheus joined
12:39 wroathe joined
12:39 meba joined
12:41 connrs joined
12:44 sdothum joined
12:45 freya joined
12:46 Micamo joined
12:49 jomg joined
12:51 fotonzade joined
12:52 govg joined
12:53 NoCreativity joined
12:55 Denthir joined
12:57 fractalsea joined
12:57 bollu joined
13:04 f-a joined
13:04 superKiller joined
13:04 Rodya_ joined
13:04 shutdown_-h_now joined
13:04 <superKiller> hello, I have a question. sudo apt-get install haskell-platform install haskell v7 , whereas i want v8.0.1, is that 'apt-gettable' ?
13:06 connrs joined
13:10 g0d355__ joined
13:10 oberstein joined
13:10 blender joined
13:10 Wheels_ joined
13:13 <Tuplanolla> Does Stack install local documentation by default? The user guide does not tell.
13:14 <Wheels_> Hey guys, I'm new to Haskell. I'm playing around with managing a list through pattern matching. Within GHCI I give the function the input "12356"
13:14 <Wheels_> http://lpaste.net/354636
13:15 <Wheels_> I get some sort of type error, but I can't figure out why
13:15 <Wheels_> Any help would be greatly appreciated!
13:15 <Tuplanolla> You seem to be missing some cases, Wheels_.
13:16 <Clint> Wheels_: what happens when you pass sol a list of lengths 1 or 2?
13:16 <Wheels_> Oooh! I will get back to you in a moment!
13:17 soniku joined
13:18 ddere joined
13:18 forgottenone joined
13:19 f-a left
13:21 <Wheels_> Can there be ambiguity in the patterns, where I control which pattern is chosen first by putting the functions in desired order?
13:21 <Tuplanolla> Yes.
13:22 <Tuplanolla> They just have to be exhaustive.
13:22 <Wheels_> Thanks a lot
13:22 <Tuplanolla> The compiler can check this if you enable warnings.
13:23 sepp2k joined
13:26 ChaiTRex joined
13:27 lipkab joined
13:28 wroathe_ joined
13:29 <Tuplanolla> Stack's user guide does mention `build: haddock: true` in `~/.stack/global/stack.yaml`, but says that it could cause build failures. Is this really a problem?
13:30 mmn80 joined
13:31 doomlord joined
13:33 sigmundv_ joined
13:34 SrPx joined
13:34 <SrPx> What are the inference rules for Fix? Can someone link me to a paper / image?
13:35 chbatey joined
13:36 iomonad joined
13:37 blender joined
13:39 <Wheels_> I figured it would be exhaustive now with the last sol function, however still getting (type) errors, I included them in the paste. http://lpaste.net/354639. Also included type signatures this time. Sorry if this is a very basic question!
13:39 BlueShark|cloud joined
13:40 BlueShark|cloud left
13:42 splanch joined
13:44 <Wheels_> Oh, the ':' operator only take a single Char on the left hand side?
13:46 nirvinm left
13:48 <tsahyt> :t (:)
13:48 <lambdabot> a -> [a] -> [a]
13:49 <tsahyt> specialized to String that is Char -> [Char] -> [Char]
13:49 <byorgey> Wheels_: in general, the ':' operator takes a single element on the left hand side and a list on the right hand side
13:50 <Wheels_> Yes, I feel silly for asking now, thanks guys
13:50 <tsahyt> It's useful to think of (:) not just as an operator but as the list constructor. Every element in a list is joined to the list after it by a (:). Indeed it actually *is* one of the list constructors, the other being []
13:51 lgandras joined
13:53 jgt1 joined
13:54 tsmish joined
13:54 psychicist__ joined
13:55 oisdk joined
13:57 chbatey joined
13:57 oldsk00l joined
13:58 sigmundv_ joined
13:58 jmcarthur joined
13:58 edvorg joined
14:01 <Wheels_> Oh yeah, [1,2,3] is just syntactic sugar for 1:2:3:[] right?
14:02 fragamus joined
14:04 <tsahyt> yes
14:05 <tsahyt> and "abc" is syntactic sugar for 'a' : 'b' : 'c' : []
14:05 <tsahyt> or for ['a','b','c'] if you prefer to desugar twice
14:05 <Wheels_> cheers! :)
14:05 <tsahyt> (unless you use OverloadedStrings)
14:05 leat joined
14:06 Denthir joined
14:08 splanch joined
14:09 chbatey joined
14:13 <fotonzade> guys I got a file like:
14:13 <fotonzade> (number of strings to read)
14:13 <fotonzade> (that number of strings)
14:13 <fotonzade> (number arrays)
14:13 leah2 joined
14:13 <bartavelle> is there an established typeclass for things that just have "pure" from Applicative, and another from things that just have "extract" from comonads ?
14:14 <fotonzade> how do I split the file up and put it into variables?
14:14 <Tuplanolla> @hackage megaparsec
14:14 <lambdabot> http://hackage.haskell.org/package/megaparsec
14:14 <tsahyt> bartavelle: Pointed for pure
14:14 <Tuplanolla> Perhaps with that package, fotonzade.
14:14 <bartavelle> tsahyt, thx
14:14 <tsahyt> bartavelle: and Copointed too
14:14 <bartavelle> oh well :)
14:14 <fotonzade> Tuplanolla, I can't use anything fancy
14:14 <Tuplanolla> Use `readMaybe` then, fotonzade.
14:14 DTZUZU joined
14:16 <fotonzade> thanks Tuplanolla
14:16 egis joined
14:17 codesoup joined
14:18 soniku joined
14:19 LeCamarade joined
14:23 anuxivm joined
14:24 augur joined
14:27 descender joined
14:30 cobreadmonster joined
14:32 Wuzzy joined
14:34 stef204 joined
14:37 blender joined
14:38 ziocroc joined
14:40 wroathe joined
14:40 soniku joined
14:40 oisdk joined
14:40 ublubu joined
14:41 Younder joined
14:42 halogenandtoast joined
14:43 aminb joined
14:43 aminb joined
14:45 tumdedum joined
14:47 lipkab joined
14:49 doomlord joined
14:50 cyborg-one joined
14:50 jgt1 joined
14:51 xall_ joined
14:51 Wedamm joined
14:54 <bartavelle> now, is there an established typeclass for "f a -> Maybe a" ?
14:55 meck joined
14:55 blender joined
14:55 paulsh94 joined
14:56 MP2E joined
14:57 atomi joined
14:57 <Gurkenglas> :t asum . fmap Just -- bartavelle, are there more examples you're thinking of than this could do?
14:57 <lambdabot> (Functor t, Foldable t) => t a -> Maybe a
14:57 <Gurkenglas> Also you might be interested in lens and using preview on its traversals
14:58 <Gurkenglas> :t getFirst . foldMap (First . Just)
14:58 <lambdabot> Foldable t => t a -> Maybe a
14:59 <bartavelle> hummm
14:59 <bartavelle> in my use case that's for things that can only ever hold a single 'a', but I am thinking about what that would mean for Foldable
14:59 zeroed joined
14:59 <bartavelle> ie. several as
15:00 <Gurkenglas> Foldable needs not be several as. Maybe is a Foldable.
15:00 <tsahyt> Gurkenglas: is that a generalization of listToMaybe?
15:00 <bartavelle> yeah but then my code would also work for []
15:01 <Gurkenglas> tsahyt, yes
15:01 <tsahyt> that's quite nice
15:01 <bartavelle> and I have to think about what that would mean
15:01 <tsahyt> really this should be in base rather than just plain listToMaybe
15:01 xmonader3 joined
15:01 <tsahyt> (getFirst . foldMap (First . Just)) (Right 1)
15:02 <tsahyt> > (getFirst . foldMap (First . Just)) (Right 1)
15:02 <lambdabot> Just 1
15:02 <tsahyt> Either to Maybe conversion is something I need every now and then too
15:02 <tsahyt> > (getFirst . foldMap (First . Just)) (Left 2)
15:02 <lambdabot> Nothing
15:02 <Gurkenglas> :t alaf First foldMap Just
15:02 <lambdabot> Foldable t => t b -> Maybe b
15:02 <tsahyt> :t alaf
15:02 <lambdabot> (Rewrapped t s, Rewrapped s t, Functor g, Functor f) => (Unwrapped s -> s) -> (f t -> g s) -> f (Unwrapped t) -> g (Unwrapped s)
15:02 <tsahyt> lens?
15:02 <Gurkenglas> Yep :P
15:02 <tsahyt> nope nope nope
15:02 <* tsahyt> runs away
15:03 <bartavelle> haha
15:03 <Gurkenglas> It temporarily steals the powers of a newtype
15:03 <Gurkenglas> :t preview _Right :: Either a b -> Maybe b
15:03 <lambdabot> Either a b -> Maybe b
15:03 <Gurkenglas> :t preview _Left :: Either a b -> Maybe a
15:03 <tsahyt> :t preview
15:03 <lambdabot> Either a b -> Maybe a
15:03 <lambdabot> MonadReader s m => Getting (First a) s a -> m (Maybe a)
15:04 <tsahyt> :t either (const Nothing) Just
15:04 <lambdabot> Either b a -> Maybe a
15:04 <tsahyt> ^ what I actually use
15:05 <Gurkenglas> :t preview (_Left . _Right) :: Either (Either a b) c -> Maybe b
15:05 <lambdabot> Either (Either a b) c -> Maybe b
15:05 <tsahyt> yeah once nesting comes into it, lens starts making some sense
15:05 <bartavelle> hum that's actually exactly a prism that I need here
15:07 aweinstock joined
15:09 <bartavelle> so, there isn't a typeclass like "HasPrism f where pr :: Prism' (f a) a" ?
15:10 bhiliyam joined
15:10 RonnieHolm joined
15:12 <Gurkenglas> bartavelle, that would mean that f is isomorphic to Either b for some b
15:12 <bartavelle> yes
15:13 <Gurkenglas> So why not use Either b?
15:13 <bartavelle> because it makes the code harder to read than several custom type
15:13 <bartavelle> also some of these types are GADTs
15:13 feynhat joined
15:13 <bartavelle> which I'm not sure how I would handle that way
15:14 <bartavelle> I like "Expr arch f a" better than "Either (NonConstant arch f a) a"
15:15 <bartavelle> even NonConstantExpr
15:15 RonnieHolm left
15:16 <bartavelle> brb
15:16 <Gurkenglas> Ohh right the a may appear on the left. Hm.
15:16 zeroed joined
15:17 <Gurkenglas> (so f isnt isomorphic to Either b)
15:17 DTZUZU joined
15:17 <Gurkenglas> *need not be
15:17 etehtsea joined
15:19 <Gurkenglas> Suddenly it feels like it doesnt deserve a typeclass :3
15:20 <Gurkenglas> Because, like, ((,) Int) has a possible instance for each Int
15:20 Krymise joined
15:26 coltfred_ joined
15:27 <Tuplanolla> I'm about to build myself a new website, but I have to make a choice first: `hakyll`, `mathblog`, `muon`, `shikensu`, `heckle` or `haggis`?
15:28 sleblanc joined
15:28 <Akii> how about just using HTML?
15:28 urodna joined
15:29 <Tuplanolla> Most of the content will be project excerpts, software documentation and research papers, so I'd rather not retype all of that, Akii.
15:30 electrostat joined
15:31 Lyraz joined
15:31 <tsahyt> I'm using hakyll. It does everything I need from it
15:31 <Wheels_> Hey guys, newbie question again: http://lpaste.net/354643. I can't figure out why this won't work, might be the point-free notation but I can't seem to fix it.
15:31 <Tuplanolla> Would it have trouble integrating with existing build systems on other file systems, tsahyt?
15:32 <tsahyt> I have no idea. I run the site builder locally and then push everything via git.
15:32 <Tuplanolla> I'd like to be able to point it to a repository and a patch and go with that.
15:33 morphit joined
15:35 <Sornaensis> :t interact
15:35 <lambdabot> (String -> String) -> IO ()
15:36 <tsahyt> Tuplanolla: I think it should be possible with some setup
15:36 <Sornaensis> Wheels_: try replacing those $ with .
15:36 <Tuplanolla> Thanks, tsahyt. I'll take that into consideration.
15:36 <Sornaensis> $ does not work in pointfree because you need an x to apply f to
15:36 <tsahyt> if I understand you correctly anyhow. hakyll allows you to process some arbitrary directory through it and tie it into your routes
15:36 <tsahyt> all the contents of the directory will be processed via pandoc or whatever you have set up
15:37 <Sornaensis> . just composes functions
15:37 Denthir joined
15:37 <Tuplanolla> I can probably launch Make etc from within Hakyll too, tsahyt.
15:37 gcross_ joined
15:37 <tsahyt> well you can launch arbitrary IO in the Rules monad, so yeah
15:38 <tsahyt> http://hackage.haskell.org/package/hakyll-
15:38 <Tuplanolla> Man, why do I have so many projects.
15:38 <Wheels_> @Sornaensis do I have to surround the map functions with parenthesis?
15:38 <lambdabot> Unknown command, try @list
15:38 fendor joined
15:38 <Tuplanolla> I even had a project whose purpose was to assign project numbers to my projects, but it stalled.
15:39 <Wheels_> Still getting type errors
15:39 dan_f joined
15:39 <Jinxit> i have some deceptively repetitive code: http://lpaste.net/3585763033156157440 any ideas for making it less repetitive?
15:39 <Tuplanolla> My recursion scheme sense tingles, Jinxit.
15:39 <Tuplanolla> Have you heard of `Fix`?
15:40 <Jinxit> the uses of Fix i've seen only concern a single type
15:40 <Jinxit> sadly i have multiple mutually recursive types
15:40 <Tuplanolla> It should still be doable, or you could inline them together.
15:41 <Jinxit> got any examples?
15:41 <Jinxit> i'm not 100% sure on how it works
15:41 soniku joined
15:41 <Jinxit> (it's 12 types, fwiw)
15:42 raycoll joined
15:42 pera joined
15:42 vektorweg1 joined
15:43 <Tuplanolla> The idea would be to have `data SourceExprF f a = ...`, where `f` carries the mutually recursive constructors and `a` is the argument for the fixed point.
15:43 <Wheels_> http://lpaste.net/354643 The compiler freaks out because of ambiguity now, is it possible to specify types within this expression?
15:43 <Tuplanolla> You could then permute `f` with the appropriate `newtype`s.
15:43 <Tuplanolla> I'm not sure how well that'd work for you though.
15:45 gcross_ joined
15:45 <Tuplanolla> If you want to keep the types as they are, the other option would be to derive `Generic` and use that to define the type class instances.
15:45 doomlord joined
15:46 <Jinxit> so in this case it would be `SourceExprF f1 f2 a = Constructor (f1 a) (f2 a) a | ..` for example?
15:46 yellowj joined
15:47 wroathe joined
15:47 <Jinxit> what would this give me? would i still have to define walkDown/Up for every single constructor by hand?
15:49 <Jinxit> it's the kind of code that i can mechanically describe, but without resorting to TH i doubt i could 'generate' it
15:49 DTZUZU joined
15:49 <Tuplanolla> I think it would be more like `data SourceExprF f c a = ConstructorF (f SourceExprF c a) [a] c | ...`.
15:50 <Tuplanolla> It's a bit tricky to say without trying it first.
15:50 insitu joined
15:50 <Tuplanolla> The idea is that `f` is sort of a continuation on the type level.
15:51 <Jinxit> yeah and it decimates any understanding you can get by reading the type definitions
15:51 mohsen_ joined
15:51 SimpleL joined
15:51 <Gurkenglas> Jinxit, shouldn't it be m' = m <> m1 <> m2?
15:51 <Jinxit> let me think
15:52 xall_ joined
15:52 <Tuplanolla> We don't do understanding around here.
15:52 <Jinxit> i believe m is already inside m1 and m2
15:54 <Jinxit> or to be specific, m has been passed to fSourceExpr (or similar) on a lower level, where it returns a new m', that shows up here as m1 and m2
15:54 Rodya_ joined
15:54 marcopullo joined
15:55 CoderPuppy joined
15:55 <glguy> Wheels_: You can write: (read :: String -> [Int]), for example
15:55 <xmonader3> I can't import Control.Monad.Reader is that still the correct module?
15:55 blender joined
15:56 <Gurkenglas> Jinxit, I conjecture that this ends up looking like this: http://lpaste.net/3585763033156157440#a354646
15:56 <Gurkenglas> Congratulations on writing code that can be abstracted away immediately
15:57 <Tuplanolla> You missed the point where `SourceExpr` and `TypeInst` are mutually recursive, Gurkenglas.
15:57 nicknovitski joined
15:57 wroathe joined
15:57 <Gurkenglas> Dammit
15:57 initiumdoeslinux joined
15:58 <Jinxit> i wish it was that easy :)
15:58 <Tuplanolla> There are ways to resolve that, but they're all equally unpleasant.
15:58 dogbitsman joined
15:58 oberstein joined
15:58 <Jinxit> full types for the curious: http://lpaste.net/6928300002460565504
15:59 <Jinxit> but SourceExpr and TypeInst are directly mutually recursive, so i suppose they are minimal in a sense
15:59 <Jinxit> as a test case
15:59 stef204 joined
15:59 <Tuplanolla> That looks oddly familiar, Jinxit. What is this for?
16:00 <Jinxit> AST for a programming language of my own invention
16:00 <Gurkenglas> I'm guessing this is one of the resolutions that are unpleasant? http://lpaste.net/3585763033156157440#a354647
16:00 <Jinxit> what's it look similar to?
16:00 <Tuplanolla> I recently discussed a very similar design with one of my former students.
16:01 <Jinxit> oh, wouldn't be me :)
16:01 trism joined
16:01 <AWizzArd> What is the difference between ap and <*>? Shouldn’t <*> also work in monadic contexts?
16:01 <Tuplanolla> You work alone?
16:01 <Gurkenglas> (Whoops just took the m out of the class signature)
16:01 <Jinxit> yeah
16:01 <Gurkenglas> AWizzArd, monad is older than applicative
16:01 <Tuplanolla> Well, someone thinks alike!
16:01 <AWizzArd> Gurkenglas: so ap survived for compatibility reasons?
16:01 <geekosaur> yes
16:02 <Jinxit> i realize the common way to do it is to use Fix and have one "ASTNode" type for everything
16:02 <Jinxit> but i couldn't stomach losing so much type information
16:02 <geekosaur> and, well, most retrodfitted Applicative instances just set <*> to ap
16:02 <AWizzArd> k
16:02 Eduard_Munteanu joined
16:03 <Jinxit> Gurkenglas: so correct me if i'm wrong, but that could automate all cases where it's self-recursive, but i'd have to write out all the other cases?
16:03 <Gurkenglas> Why didn't GHC magically add Applicative instance for every monad that didn't define them in order to not break things?
16:03 Krymise joined
16:04 <Tuplanolla> You'd have to extend it the way I first described, Jinxit.
16:04 beanbagula joined
16:04 <Tuplanolla> The `Functor` instance would break otherwise (try it and see).
16:04 Icewing joined
16:04 <geekosaur> Gurkenglas, because doing so is painful. I've been watching someone (dfeuer I think?) trying to add deriving code and getting a massive headache
16:05 c0mrade joined
16:05 <monochrom> I am philosophically against such magic. It makes the language more ad hoc.
16:06 mac10688 joined
16:06 <Jinxit> speaking of applicative - do 'many' and 'some' make sense outside of parsers?
16:07 <c0mrade> Can anyone help me troubleshoot a problem in an app, I've got it running but getting an exception, it's a web app. Here's some info about the app and how to set it up. https://github.com/ornicar/lila and https://github.com/ornicar/lila/wiki/Lichess-Development-Onboarding
16:07 wroathe joined
16:09 <monochrom> many and some makes sense iff an action succeeds the first few times but if you keep doing it it eventually fails.
16:09 osa1 joined
16:09 hybrid joined
16:09 <monochrom> To a large extent that describes parsers and input takers.
16:09 <Jinxit> that's a good explanation
16:10 <Gurkenglas> Or it doesnt work immediately, or it keeps working forever
16:10 <Gurkenglas> *"immediately doesnt work"
16:10 <monochrom> I can also think up a "decrease internal counter until zero" example but it's artificial not real.
16:10 fragamus joined
16:12 <monochrom> No, Gurkenglas, Maybe is an example of always-succeeds and always-fails and precisely because of this, many and some are problematic for Maybe, problematic being either bottom or trivial.
16:12 grim_ joined
16:13 <monochrom> trivial being "yeah, some Nothing and some (Just 5) are OK, but why would you care"
16:13 cpup joined
16:14 jden joined
16:15 <AWizzArd> What is the core motivation of having an IO Monad? Is it so that there is a “marker” in the type signature that tells that somewhere down the chain there IS some IO going on? That way devs can immediately see if they do a pure or impure computation.
16:15 a3Dman joined
16:15 <AWizzArd> Was that the design goal? IO is a monad so that IO is explicit?
16:16 <geekosaur> that's a large part of it, yes, it keeps the impure stuff separate
16:16 <geekosaur> but it also enforces sequencing, so you know IO actions take place in the right order
16:16 sleffy joined
16:16 robotroll joined
16:16 <AWizzArd> Yes good point.
16:17 wroathe joined
16:19 <Gurkenglas> monochrom, no, Maybe can represent failing sometimes. See StateT s Maybe and https://hackage.haskell.org/package/pointedalternative-
16:21 maxirater joined
16:21 <Gurkenglas> (And many (Just 2) ought to be repeat 2)
16:21 oisdk joined
16:22 yellowj joined
16:23 albertus1 joined
16:24 albertus1 joined
16:25 albertus1 joined
16:26 insitu joined
16:27 danzimm joined
16:27 revprez_atlanta joined
16:27 oberstein joined
16:27 Aruro_ joined
16:28 wroathe joined
16:30 lipkab joined
16:30 <cheater> :t many
16:30 <lambdabot> Alternative f => f a -> f [a]
16:31 <cheater> :i Maybe
16:31 <cheater> o
16:33 DTZUZU joined
16:33 Wedamm joined
16:33 zeroed joined
16:35 <cheater> welp
16:35 <cheater> it seems like that's not correct, Gurkenglas.
16:36 <cheater> it would be something like Just $ repeat 2.
16:38 nbro joined
16:38 Destol joined
16:40 danzimm joined
16:41 <Gurkenglas> uh of course, I must have been elsewhere mentally
16:41 meba joined
16:42 insitu joined
16:43 Discovery joined
16:44 fragamus joined
16:45 agjacome joined
16:48 bab joined
16:50 boxscape joined
16:53 Tesseraction joined
16:53 splanch joined
16:53 soniku joined
16:53 <nshepper1> > many (Just 2)
16:53 <lambdabot> mueval-core: Time limit exceeded
16:54 <c_wraith> nshepper1: some and many don't really work for a lot of instances of Alternative
16:54 <c_wraith> nshepper1: they mostly work with things that are parser-like.
16:54 <nshepper1> I've only seen them work for parsers lol
16:55 <c_wraith> I guess in theory, they can work with anything state-like
16:55 augur joined
16:55 <c_wraith> parsers just happen to be state-like in a way that makes them always work.
16:56 <nshepper1> They can "work" with any action that can "sometimes fail", right?
16:56 blender joined
16:56 laplacian joined
16:57 <nshepper1> many . pure is probably never going to do anything useful, because pure never fails
16:58 bhiliyam joined
16:58 fnurglewitz joined
16:58 Edith joined
17:00 jomg joined
17:00 CoderPuppy joined
17:01 ubsan_ joined
17:02 <xcmw> Is there any downside to using
17:02 <xcmw> freer-effects over transformers
17:05 DTZUZU joined
17:06 a3Dman joined
17:09 conal joined
17:10 beanbagu1 joined
17:10 mmhat joined
17:10 OscarZ joined
17:11 Krymise joined
17:13 stevebash joined
17:13 {emptyset} joined
17:14 sleffy joined
17:14 MoALTz joined
17:16 LiaoTao joined
17:20 Ralith_ joined
17:22 cfricke joined
17:25 Goplat joined
17:26 RegEchse joined
17:27 fragamus joined
17:28 DTZUZU joined
17:29 <c_wraith> xcmw: some effects don't commute. In the cases where you're using a set of effects that doesn't commute, freer-effects doesn't let you specify the order they need to happen in, but transformers does.
17:30 meck joined
17:30 chirpsalot joined
17:30 a3Dman joined
17:30 Chobbes joined
17:31 <xcmw> c_wraith: Don't they run in the order you run them in in both freer-effects and transformers?
17:33 <c_wraith> xcmw: they run in the order you specify the run operations, sure. But with mtl/transformers, you can make it a type error to run them in the wrong order. You can't do that with freer-effects
17:35 chbatey joined
17:37 dfeuer joined
17:38 gawen joined
17:38 richi238 joined
17:39 a3Dman joined
17:40 wroathe joined
17:40 Rodya_ joined
17:41 shane joined
17:41 blender joined
17:42 meba joined
17:45 Denthir joined
17:46 shivansh joined
17:48 cfricke joined
17:50 Wedamm1 joined
17:52 tomboy64 joined
17:52 mazeinmaze_ joined
17:53 thunderrd_ joined
17:53 shane joined
17:54 soniku joined
17:58 nomicflux joined
17:58 splanch joined
18:00 _sg joined
18:02 ericmathison joined
18:02 dogui joined
18:04 blender joined
18:05 azahi joined
18:05 athan joined
18:05 chichou joined
18:07 _sg2 joined
18:07 yellowj joined
18:09 alexbiehl joined
18:10 NyanPasu joined
18:12 <Tuplanolla> John A De Goes gave a talk about this recently, xcmw.
18:12 <Tuplanolla> Here's the recording: https://www.youtube.com/watch?v=JLevNswzYh8
18:13 ertesx joined
18:15 <dmj`> 11198 for # of hackage packages, does that sound right
18:17 mada joined
18:19 NyanPasu joined
18:20 blender joined
18:25 chbatey joined
18:25 <reactormonk[m]> To publish a package, should I read cabal or stack docs?
18:26 <monochrom> To publish it on hackage, read cabal docs. To publish it on stackage, read stack docs. To do both, read both docs.
18:26 shivansh left
18:29 azahi joined
18:29 <dmj`> reactormonk[m]: cabal check, cabal sdist, cabal upload dist/*.tar.gz
18:30 amut joined
18:31 <dfeuer> reactormonk[m]: you should definitely publish on Hackage if you're publishing; Stackage is downstream from there.
18:31 <reactormonk[m]> A bit more specific, I wanted to create a package containing instances for aeson for a custom data type - which package name should it go to?
18:31 <reactormonk[m]> kk
18:32 fabianhjr joined
18:32 <reactormonk[m]> Orphan instances, etc.
18:33 <Tuplanolla> How about `aeson-x-orphanage` with your type in place of `x`?
18:35 iqubic joined
18:36 <iqubic> Hello Guys
18:41 biglama joined
18:44 watabou joined
18:46 bhiliyam joined
18:46 a3Dman joined
18:48 oisdk joined
18:48 cfricke joined
18:48 Guest83 joined
18:49 sleffy joined
18:52 splanch joined
18:53 aarvar joined
18:53 eazar001 joined
18:53 sigmundv_ joined
18:54 soniku joined
18:54 rcat joined
18:56 fractalsea joined
18:58 watabou joined
18:58 <ertes> are ixset and ixset-typed still state of the art?
18:58 iomonad joined
18:59 Rodya_ joined
19:00 insitu joined
19:01 insitu joined
19:02 xinming_ joined
19:03 leat joined
19:03 _jlt joined
19:10 systemfault joined
19:11 carlosda1 joined
19:14 doomlord joined
19:15 jud joined
19:15 jud joined
19:16 kamyar joined
19:17 des_ joined
19:18 darlan joined
19:19 <kamyar> hi all
19:19 <kamyar> please help me with this wuestion
19:19 <kamyar> question
19:19 meoblast001 joined
19:22 fractalsea joined
19:22 coot joined
19:23 verement joined
19:24 <geekosaur> you have to ask it to get help...
19:25 ubsan_ joined
19:28 <tsahyt> Is it possible to partially apply a type family?
19:28 negatratoron_ joined
19:28 negatratoron joined
19:28 chirpsalot joined
19:28 Chobbes joined
19:28 <kamyar> geekosaur: I need help about MessagePack
19:28 <kamyar> and I want to paste code
19:28 <hpc> tsahyt: no, type families behave like type aliases in that respect
19:28 <geekosaur> tsahyt, no, type level things can't be partially applied
19:28 <tsahyt> okay thanks
19:29 <hpc> tsahyt: iirc you can partially apply data families
19:29 <geekosaur> @paste -- kamyar, code goes here
19:29 <lambdabot> Haskell pastebin: http://lpaste.net/
19:29 tobiasBora joined
19:29 <tsahyt> hpc: thanks, that might be worth a look
19:30 <kamyar> Ths is code : http://lpaste.net/256818986803527680
19:30 danthemyth joined
19:31 <tsahyt> hmm, there's no such thing as closed data families I suppose?
19:31 Hail_Spacecake left
19:32 <kamyar> Any help?
19:35 <glguy> tsahyt: GADTs?
19:35 <tsahyt> ah right
19:36 <geekosaur> kamyar, so what is the question?
19:36 grim__ joined
19:36 Wedamm1 joined
19:37 <kamyar> geekosaur: The part defining MessagePack instance is buggy
19:37 <kamyar> geekosaur: I just copied from Json but it is wrong
19:37 fryguybob joined
19:38 Sh4rPEYE joined
19:38 <Sh4rPEYE> I have hlint 1.9 installed with stack. How do I update it?
19:38 <cocreature> Sh4rPEYE: how exactly did you install it?
19:39 <cocreature> Sh4rPEYE: the short answer is: build a newer version and copy it to ~/.local/bin. for the latter you can use "stack install". how you build a newer version is up to you. one solution is to bump your global snapshot
19:39 <cocreature> another is to tell stack to install a specific version
19:39 <cocreature> or just checkout the hlint git repo
19:39 darlan joined
19:40 <Sh4rPEYE> stack install hlint, I think
19:40 kamyar joined
19:41 <kamyar> geekosaur: Anyone answered?
19:41 <geekosaur> kamyar, I cannot answer this as I don;t use the web stuff
19:41 <geekosaur> but, so far what I know is exacly what you said.
19:42 <geekosaur> which is to say, not how it is buggy, not what errors it gave you or what behavior you expected vs. the behavior you got.
19:42 wroathe joined
19:42 <geekosaur> and drawing details out little by little becomes tiring
19:42 shadow-x joined
19:43 c0mrade joined
19:43 c0mrade joined
19:43 c0mrade joined
19:45 darlan joined
19:45 soniku joined
19:45 Sh4rPEYE joined
19:47 jmcarthur joined
19:49 ericmathison joined
19:49 xcmw joined
19:54 Sh4rPEYE joined
19:55 ziocroc joined
19:56 slack1256 joined
19:59 eschnett joined
20:00 jeltsch joined
20:01 Rodya_ joined
20:02 Ferdirand joined
20:04 roth joined
20:06 bollu joined
20:06 <bollu> do failed pattern matches inside "do" use MonadFail?
20:06 chbatey joined
20:08 <glguy> eventually
20:08 <cocreature> atm they use Monad’s fail method
20:08 <glguy> and specifically in the case of: pattern <- expression
20:09 <glguy> (not other lets or cases)
20:09 recycletrash joined
20:10 epsilonhalbe1 joined
20:10 thewormkill joined
20:11 acarrico joined
20:12 <cocreature> huh, apparently 8.0 already includes a -XMonadFailDesugaring extension that uses the new MonadFail class
20:14 ph88 joined
20:14 <Gurkenglas> https://www.haskell.org/cabal/release/cabal- <- "MonadFailDesugaring
20:14 <Gurkenglas> A temporary extension to help library authors check if their code will compile with the new planned desugaring of fail."
20:14 <dfeuer> Nice. When't the change happen for real?
20:15 chrissl joined
20:17 <Tuplanolla> Should I put `build: haddock: false` into `~/.stack/config.yaml` or `~/.stack/global/config.yaml`? The documentation doesn't say.
20:17 <dfeuer> Tuplanolla: that's because stack is poorly documented, IME.
20:18 <cocreature> Tuplanolla: I don’t think that has any effect since stack doesn’t build haddocks by default anyway
20:18 <cocreature> Tuplanolla: what are you trying to do?
20:18 <Tuplanolla> I want offline documentation for everything I install.
20:19 <cocreature> in that case don’t you want "haddock: true" instead of "haddock: false"?
20:19 <Tuplanolla> I do.
20:19 <cocreature> (I don’t know whether that works)
20:20 zcourts joined
20:21 xdelv joined
20:21 m0rphism joined
20:21 sleffy joined
20:21 a3Dman joined
20:22 <Tuplanolla> It's not at all clear if I even want Stack.
20:22 fotonzade joined
20:22 mounty joined
20:22 <cocreature> Tuplanolla: https://github.com/commercialhaskell/stack/issues/880#issuecomment-230757744 seems like it does what you want
20:23 acarrico joined
20:23 <Tuplanolla> Which file?
20:23 Itkovian joined
20:24 <cocreature> I think config.yaml should work
20:24 <cocreature> the other is for your global project not for global config options
20:24 nakal joined
20:24 <Tuplanolla> Very well; thanks.
20:24 <recycletrash> Hello, I was hoping someone could explain to me why this function is named accordingly. twiceOptional :: (a -> b -> c) -> Optional a -> Optional b -> Optional c ... twiceOptional f = applyOptional . mapOptional f
20:25 <cocreature> recycletrash: probably “twice” comes from receiving two Optional arguments and Optional comes from those arguments being optionals
20:26 <geekosaur> because it checks both Optional-s and shortcircuits for either, otherwise produces the result of applying the function
20:26 systemfault joined
20:27 zcourts joined
20:29 revprez_atlanta joined
20:29 <recycletrash> Ah thanks. geekosaur & cocreature just made the light bulb go off.
20:29 nakal joined
20:29 plutoniix joined
20:33 sleffy joined
20:34 soniku joined
20:35 bhiliyam joined
20:35 <monochrom> This is why I hate English. When the light bulb turns on, it goes off.
20:36 xmonader3 joined
20:38 <Tuplanolla> If x, y, z, as expected.
20:39 revprez_atlanta joined
20:39 <Tuplanolla> (Replace variables with expressions to recover four different meanings.)
20:41 mjz19910 joined
20:43 dejanr joined
20:44 <recycletrash> Yes, I apologize for the english expression. It most likely has to do with "goes off", often meaning happens suddenly.
20:45 sleffy joined
20:45 <geekosaur> yeh, but its especially unfortunate for light bulbs because you prefer them not to act like flashbulbs :p
20:45 heinrich5991 joined
20:46 <recycletrash> True. It's too bad english lightbulbs have to work twice as hard.
20:47 aarvar joined
20:47 Avogadro joined
20:49 Salih joined
20:51 Salih joined
20:53 mjz19910 joined
20:53 pera joined
20:54 mjz19910 joined
20:55 <fotonzade> hey guys
20:55 <fotonzade> I'm back
20:56 <fotonzade> I read the contents of a file and I want to break it into an array of lines
20:56 <fotonzade> main = do
20:56 <fotonzade> [f] <- getArgs
20:56 <fotonzade> content <- readFile f
20:56 <fotonzade> [hargle] <- lines content
20:56 <fotonzade> what am I doing wron ghere
20:56 <fotonzade> I'm getting this error
20:56 <fotonzade> parse error on input ‘<-’
20:56 <fotonzade> Perhaps this statement should be within a 'do' block?
20:56 <geekosaur> sounds like indentation, so piut the actual code somewhere
20:56 <geekosaur> @paste
20:56 <lambdabot> Haskell pastebin: http://lpaste.net/
20:56 <geekosaur> ^
20:57 <geekosaur> that said I seea logic error
20:57 <geekosaur> [f] means match a 1-argument list
20:57 <fotonzade> ah
20:57 <geekosaur> likewise [hargle] means match a 1-element list... hope your file has one line in it
20:57 <geekosaur> also: lines is pure, use let not <-
20:57 <geekosaur> use <- when doing something in IO, like readFile
20:58 <thang1> I would've assumed [f] meant matching on a list of type f since that's what it is in type signatures
20:58 sleffy joined
20:58 epsilonhalbe1 left
20:58 <fotonzade> let hargle = lines content ?
20:58 <geekosaur> fotonzade, yes
20:58 <fotonzade> gives me a parse error :(
20:58 <fotonzade> 47:9: parse error on input ‘let’
20:58 <geekosaur> again you still have that indentation issue
20:58 <fotonzade> I'm using tabs
20:58 <fotonzade> is that a problem :(
20:58 <geekosaur> repeating: put the actual code, and the full actual error message, in the pastebin
20:58 <fotonzade> okay cool
20:58 <geekosaur> @paste
20:58 <lambdabot> Haskell pastebin: http://lpaste.net/
20:59 <thang1> fotonzade: tabs "aren't" a problem, but your life becomes much easier if you use pure spaces for everything.
20:59 <geekosaur> and yes, tabs can be a problem. especially if mixed with spaces, because editors don't always agree how tabs and spaces match up
20:59 <fotonzade> http://paste2.org/kAh6CCvn
20:59 <fotonzade> oh theres a haskell pastebin, I'll use that
20:59 <fotonzade> from now on. my code is above
21:00 <mauke> fotonzade: look at your paste
21:00 <fotonzade> ah it IS indentation
21:00 <fotonzade> thanks a lot guys
21:00 <thang1> No problem
21:00 splanch_ joined
21:01 <thang1> Also your allEqual looks really complicated for what should be a super simple function...
21:01 <thang1> I'm also of the opinion that if you have to comment your data types with what they represent, your data types aren't useful enough :p
21:01 <fotonzade> thang1, the problem is that I really dont know haskell
21:02 <fotonzade> and I have an assignment
21:02 <thang1> No problem! We're all here to learn
21:02 <fotonzade> I am having conflicting feelings about haskell
21:02 <fotonzade> its really cool but also infuriating
21:02 <thang1> Ahh you're learning from a class? What learning materials are y'all using?
21:02 <fotonzade> Thompson's textbook IIRC
21:02 alx741 joined
21:03 tput joined
21:03 splanch joined
21:03 <Tuplanolla> That's normal, fotonzade. Haskell is an ugly language for beautiful ideas.
21:04 <thang1> That looks like a horrifying textbook to learn haskell from...
21:04 mjz19910 joined
21:04 <fotonzade> :D I just look at slides and LYAHFGG
21:05 <thang1> That book isn't super great for haskell either :p I much prefer Haskell from First Principles (which I'm learning from)
21:05 <geekosaur> .oO { I must not tab. tab is the code-killer. ... }
21:05 <dfeuer> If you really want to use tabs, use dmwit_'s style.
21:05 a3Dman joined
21:06 <thang1> for example, I look at your allEqual function and immediately think of foldl or simple recursion
21:06 <Cale> If you really want to use tabs, reconsider your life choices.
21:06 <thang1> (folding is also recursion)
21:06 jmnoz joined
21:06 <dfeuer> Cale: now now, tabs are really useful if you have a typewriter!
21:07 <maerwald> spaces increase file size
21:07 <dfeuer> Very true.
21:07 <Tuplanolla> Trailing spaces do that more elegantly.
21:07 sleffy joined
21:07 <maerwald> I thought those are dead
21:07 <* mniip> is a proud tab user
21:08 Rodya_ joined
21:08 <dfeuer> Spaces probably do actually increase the size of a large project (like GHC) substantialy.
21:08 <iqubic> I use spaces always
21:08 <dfeuer> It's probably best to avoid whitespace altogether, and just use braces and semicolons as necessary.
21:08 <mniip> dfeuer, that is easily defeated with virtually any compression algorithm
21:09 Sam__ joined
21:09 <dfeuer> mniip: for sure, but that doesn't help save disk space....
21:09 <dfeuer> (Unless you're using a compressed filesystem, and who does that?)
21:09 <fotonzade> s/\t/ /
21:10 <maerwald> dfeuer: yeah, probably has a real impact on world-wide resource consumption
21:11 <Cale> lol
21:11 <dfeuer> What is funny?
21:11 mjz19910 joined
21:11 <Cale> I have entire series of television shows on my drive
21:11 <maerwald> do they use tabs?
21:11 <thang1> fotonzade: Your allEqual function can also be written as : allEqual xs = and $ map (== head xs) (tail xs)
21:11 <mniip> $ du -hd 0 ghc
21:11 <mniip> 2.0G ghc
21:11 <mniip> that's a couple episodes
21:11 <thang1> or, alternatively: allEqual xs = all (== head xs) (tail xs)
21:12 fnurglewitz joined
21:12 <fotonzade> thang1, I realize that that is cooler
21:12 <fotonzade> but I really dont trust myself to understand that
21:12 <mniip> thang1, I'd replace tail with drop 1
21:12 <mniip> then you can avoid the empty list case
21:12 <[exa]> tabs vs spaces on #haskell? like, isn't there a text editor that abstracts that problem out transparently?
21:12 <maerwald> [exa]: oh you xD
21:12 <thang1> (tail in this case still works with empty lists because map does not evaluate the nodes, just hte spine)
21:12 <thang1> s/hte/the/
21:13 <mniip> no?
21:13 <mniip> @let allEqual xs = all (== head xs) (tail xs)
21:13 <lambdabot> Defined.
21:13 <mniip> > allEqual []
21:13 JuanDaugherty joined
21:13 <lambdabot> *Exception: Prelude.tail: empty list
21:13 <thang1> oh whoops nvm
21:13 <mniip> @let allEqual' xs = all (== head xs) (drop 1 xs)
21:13 <lambdabot> Defined.
21:13 <mniip> > allEqual' []
21:13 <lambdabot> True
21:13 <thang1> if you write it as: and $ zipWith (==) xs (tail xs)
21:13 <thang1> then it works with empty lists
21:13 <Cale> [exa]: It's not really much of a debate here -- all actual Haskell projects use spaces.
21:14 <mniip> thang1, that depends on the zipWith implementation
21:14 <mniip> which I'd advise to avoid
21:14 <thang1> True, good points. I don't really use it much for that reason
21:14 <Cale> [exa]: The reason for this is that it actually matters which column things line up in, so the fact that different editors treat tabs differently is just unacceptable.
21:14 <hpc> because haskell is alignment-sensitive, the tab stop behavior was chosen to match the typical defaults of text editors
21:14 <hpc> that
21:14 <hpc> and of course, those defaults are awful
21:15 <hpc> so tab moves alignment to the next 8-space tab stop
21:15 <Athas> Doesn't GHC warn about tabs these days?
21:15 <mniip> -fno-warn-tabs
21:15 <Cale> You can set your tabstops to be multiples of 8 spaces, and that'll match what the compiler treats them as, but people will *still* hate you, because their editor might not treat them that way.
21:15 <maerwald> is alignment-sensitivity really part of the report?
21:15 Sampuka joined
21:15 <Cale> yes
21:15 <hpc> yes
21:15 <thang1> fotonzade: Your solution checks the length a lot. So it'll perform pretty terribly, and it's also not very understandable compared to the other ones
21:15 <mniip> Cale, not if your code is not sensitive to the tab width
21:16 <Cale> Well, sure, you can very carefully avoid it
21:16 <thang1> "and" and "all" are very standard functions. So are things like map. They're difficult to really grasp at times, but once you understand them, they're very powerful
21:16 <hpc> fwiw, i hate when people use tabs even when it doesn't matter
21:16 <fotonzade> :(
21:16 <Cale> hpc: Yeah, me too.
21:16 <mniip> fite me
21:16 <maerwald> we should write a tab-safe subset of haskell
21:16 <hpc> seeing code randomly decrease in indentation because i have a different stop size is frustrating
21:16 <thang1> It's all good. Trust me, I wrote super terrible shit when I first started writing haskell. I still suck at it for anything that isn't trivial
21:16 <Cale> maerwald: That's easy, just always use braces and semicolons
21:16 wroathe_ joined
21:16 <hpc> and i use :set list in order to see the true contents of a file in vim
21:17 <hpc> so tabs show up as ^@
21:17 <Cale> maerwald: Then it's whitespace insensitive.
21:17 <maerwald> Cale: like SPJ? :P
21:17 <mniip> ^@ ?
21:17 <mniip> not ^I ?
21:17 <mniip> that would make more sense
21:17 <hpc> i have seen both
21:17 <thang1> You can customize which symbol you see for tabs
21:17 <hpc> looks like it's ^I on this machine
21:17 <monochrom> Indent by 3.14159 spaces.
21:17 <thang1> I have a unicode -> arrow for my tab with :set show
21:18 <dfeuer> I hate to see excessive braces and semicolons, but SPJ has the cred to do whatever the heck he wants.
21:18 <Cale> SPJ looking out for the blind Haskell users.
21:18 ft3 joined
21:19 <thang1> Anyway, I wanted to ask: I'm really interested in summer of haskell and really want to get in to that.
21:19 mjz19910 joined
21:19 <dfeuer> Cale: I think blind programmers probably need to use tools that understand Haskell syntax well anyway.
21:19 <Cale> Yeah, probably.
21:19 <thang1> Only problem is I'm still around chapter 11 of HFFP (I plan to try and finish before summer). I don't quite know what sorts of projects the community is interested in, though.
21:19 <[exa]> anyway, I always wanted to ask whether there isn't an utf blank that would mean "indent one level in". That would probably solve all this
21:20 <monochrom> We do have a blind Haskell user. We should ask them.
21:20 <thang1> Anyone have any sorts of suggestions for me to look into?
21:20 <Cale> [exa]: Well, what's "one level"?
21:20 biglama joined
21:20 <hexagoxel> one space
21:20 <dfeuer> monochrom: who's "we"?
21:20 <monochrom> The Haskell community.
21:21 mjz19910 joined
21:21 Denthir joined
21:21 <monochrom> The only way I knew was because they asked people on haskell-cafe to cut back on attachments because attachments messed with their screen reader.
21:21 <[exa]> Cale: one level in current indentation. Like a tab, but without that ugly 8space measure stuck to it
21:21 <hexagoxel> you could just configure your editor so it shows multiple spaces per space. and use single-space indentation.
21:21 <Cale> [exa]: It matters which column things align to, since that determines whether they're a continuation of a block (the first non-whitespace character following a layout keyword sets the block depth), or close it (if they're shallower than that column), or are a continuation of a line in that block (if deeper than that column)
21:22 augur joined
21:22 <[exa]> hexagoxel: that would do it, thanks for inspiration
21:22 <dfeuer> Ah. According to http://stackoverflow.com/a/2149878/1477667 at least one blind Haskell programmer uses braces and semicolons. Or did back in 2010.
21:22 <monochrom> Or maybe it was just non-ascii characters.
21:23 <Tuplanolla> I just have to say that two space per level is nice, because most fonts are about 1:2, so levels are built from squares.
21:23 <Cale> Yeah, my tab key is set to insert 2 spaces
21:23 mjz19910 joined
21:24 augur joined
21:24 <thang1> I honestly have never really gotten my tab key where I want it in emacs so I just kinda don't really bother with it
21:25 mjz19910 joined
21:25 <[exa]> Cale: I thought that's easily decided by just counting columns (exactly the count of "magic spaces"). But I wouldn't like to be the actual editor trying to guess where to put which column. Good point
21:25 <boxscape> thang1 you just press space repeatedly?
21:25 <Cale> [exa]: You can have stuff like:
21:25 <monochrom> I like tibbe's advice on this. Four spaces because it's two spaces for "where" and two more spaces for the rest. Also makes "main = do { ... } where {...}" unmisleading.
21:25 <Cale> foo x y = let z = ...
21:26 <Cale> Now the following line has to line up with the z in order to be a continuation of the let
21:26 <thang1> pffh no, boxscape, I use spacemacs. I just use tab wherever and get things to close-enough and then let hindent and stylish-haskell take care of everything else
21:26 JuanDaugherty left
21:26 <thang1> I don't write enough haskell at a high enough level to be particular, yet.
21:27 recycletrash joined
21:27 <boxscape> So you do use tab. I parsed "I don't really bother with it" as meaning that you don't
21:27 <fotonzade> guys is there an easy way to split a string like "4 3 2 1" into an array from the spaces
21:27 <boxscape> > words "4 3 2 1" -- this?
21:27 <lambdabot> ["4","3","2","1"]
21:27 <Cale> What I *would* really like is if my editor understood the layout rule properly and was able to move an entire block of code correspondingly whenever an edit caused the first non-whitespace character following a layout keyword to change position.
21:27 xcmw joined
21:28 oisdk joined
21:28 <boxscape> admittedly, that's a list, not an array, but if you really do want an array, a list is a good starting point
21:28 <[exa]> Cale: doesn't there have to be "in"? (maybe not, I don't know many details about hs syntax)
21:28 <Cale> boxscape: We use the tab *key*, but apart from a few weirdos here, not tab characters
21:28 <[exa]> :]
21:28 <Cale> [exa]: yeah, but you might want to put more definitions inside the let portion
21:28 <boxscape> Cale: right, but thang1 talked about their tab key
21:28 <Cale> ah
21:28 splanch joined
21:29 <monochrom> Now you get to debate over using the tab key vs the capslock key. :)
21:29 mjz19910 joined
21:29 <Cale> I have caps lock as compose :)
21:29 <boxscape> I just have capslock mapped to escape
21:29 <Tuplanolla> Caps Lock for Hyper.
21:29 <[exa]> Ctrl here
21:30 <monochrom> Also ripe for a dvorak keyboard joke.
21:30 <monochrom> "I use the Q key for quotes" or something.
21:31 <[exa]> actually thinking about remapping tab to something after the discussion here, escape looks useful :]
21:31 <rightfold> I remapped numpad to additional function keys
21:32 mjz19910 joined
21:32 <Tuplanolla> I'm surprised you didn't all die trying to figure out XKB.
21:32 codesoup joined
21:32 <[exa]> :]
21:33 <monochrom> We did. Satisfaction brought us back.
21:33 <monochrom> "Curiosity kills the cat. Satisfaction brings it back!"
21:33 <thang1> My caps is control + escape :p
21:33 <rightfold> Windows Registry, actually.
21:33 aarvar left
21:33 <boxscape> I use xmodmap and AutoHotkey, depending on OS
21:34 sophiag joined
21:34 splanch joined
21:34 <thang1> I use xkb but not super extensively
21:34 <geekosaur> you have to remap the numpad? try application keypad mode >.>
21:34 <geekosaur> alhtough I guess x11 makes that harder...
21:35 <thang1> I'd love to have an insane setup like this http://stevelosh.com/blog/2012/10/a-modern-space-cadet/
21:35 <* geekosaur> also uses wincompose on windows, so the compose key acts the same everywhere
21:35 cyborg-one joined
21:35 splanch_ joined
21:35 <thang1> Well if nobody has any advice about Summer of Haskell, I'll start on my quantum computing homework
21:35 <rightfold> My setup is Linux in a VM for development, and Windows as host for Chrome, Spotify and games. Because drivers.
21:36 <thang1> man, fuck drivers. I feel your pain. I still haven't bothered to get printer drivers installed on arch linux... I'm sure it's easy, but I just can't be fucked
21:36 anuxivm joined
21:36 <Tuplanolla> How did we end up here?
21:36 <rightfold> Linux as workstation but not in a VM is too difficult IMO :)
21:37 <Cale> It's not that difficult
21:37 <* geekosaur> got epson drivers for debia/ubuntu/mint easily enough
21:37 splanch__ joined
21:37 <fotonzade> guys
21:37 <fotonzade> extractVotes :: Int -> [String] -> [[Int]]
21:37 <fotonzade> extractVotes num textlines = [singleVote x | x <- (splitAt (num+1) textlines !! 1)]
21:37 <geekosaur> also I do linux as a workstation... but I don't do much in the way of games. that's what the game console is for :p
21:37 <fotonzade> what's wrong with my list comprehension
21:38 <fotonzade> http://paste2.org/ZNzpeV7L
21:38 <fotonzade> ^ error output
21:38 <Cale> fotonzade: splitAt (num+1) textlines is a pair
21:38 <Cale> !! wants a list
21:38 <geekosaur> :t splitAt
21:38 <lambdabot> Int -> [a] -> ([a], [a])
21:38 <thang1> Most of my problems in haskell can be solved with the glorious :t command
21:38 <thang1> It's amazing
21:38 <Cale> But also, just never use (!!)
21:39 <iqubic> I like it.
21:39 <geekosaur> also note that splitAt only goes off once
21:39 <iqubic> Why should you never use (!!)?
21:39 <monochrom> fotonzade: What is a typical example of the [String] parameter?
21:39 <fotonzade> cool
21:39 <boxscape> is there a safe version of (!!)?
21:39 <iqubic> :t (!!)
21:39 <lambdabot> [a] -> Int -> a
21:39 <thang1> I find !! to be useful in small doses and sparingly, but if you're trying to find the indicies of things all the time, it's not very functional
21:39 <geekosaur> safety isn;t really the issue
21:39 <geekosaur> it's *slow*
21:39 <Cale> Because it kills your program if the index is out of bounds, and it's slow
21:39 <geekosaur> because lists are not arrays
21:39 <Cale> If you need !!, you shouldn't have been using a list to begin with
21:39 <thang1> It's also not really the right way to think about things, I've found. aka ^
21:40 <boxscape> I mean, if you have (!! 2) in your code, it's constant runtime
21:40 <geekosaur> fotonzade, in any case I suspect you didnot want splitAt
21:40 <geekosaur> :t chunksOf
21:40 <monochrom> And yeah, there is something to be said about a program both slow and incorrect :)
21:40 <lambdabot> Int -> [e] -> [[e]]
21:40 <Cale> Yeah, there are cases where you just don't really care very much and it's convenient that (!!) exists
21:40 <Cale> But generally, avoid it.
21:41 xmonader3 joined
21:41 <Cale> thang1: It's not so much that it's not functional, but that it doesn't go well with linked lists
21:41 <boxscape> I found it a bit annoying that there's no safe version of Data.Array.!, unless I missed it
21:41 ericmathison joined
21:41 <Cale> thang1: This would be true of linked lists in any language
21:42 <monochrom> boxscape: You didn't miss it. Data.Array was specified at a time people didn't care about that.
21:42 <boxscape> I see
21:42 <geekosaur> for most things you probably want Vector instead of Array
21:42 <boxscape> that's good to know
21:42 <geekosaur> although Array certainly hs its uses
21:42 <thang1> Cale: that's what I was getting at, but you articulated it better. Thanks
21:43 <geekosaur> but Vector is what most people are thinking of when they think list/array
21:43 <dfeuer> I kind of like the arrays in the primitive package.
21:44 meba joined
21:44 <boxscape> what's the difference between head and unsafeHead in Vector? the types are the same...
21:45 <monochrom> head still does a bound-check and bottoms out. unsafeHead doesn't even try that.
21:45 <monochrom> unsafeHead is directly C's "a[0]"
21:45 <boxscape> ah, ok, that makes sense
21:45 bollu joined
21:47 Krymise joined
21:47 biglambda joined
21:49 <iqubic> What is bottom?
21:49 <iqubic> Or undefined?
21:50 <Cale> Bottom is the mathematical value which we assign to nonterminating computations, or ones whose evaluation throws an exception
21:50 pera joined
21:50 xmonader2 joined
21:50 <Cale> Its name comes from a partial ordering on each type, of which it is the minimum value
21:51 <iqubic> So something like sqrt -1?
21:51 <iqubic> :t sqrt
21:51 <lambdabot> Floating a => a -> a
21:51 binaryplease joined
21:51 <iqubic> > sqrt -1
21:51 <lambdabot> error:
21:51 <lambdabot> • No instance for (Typeable a0)
21:51 <lambdabot> arising from a use of ‘show_M47739095637439521496725’
21:51 <Cale> sqrt (-1) :: Complex Double
21:51 <Cale> > sqrt (-1) :: Complex Double
21:51 <lambdabot> 0.0 :+ 1.0
21:51 <Cale> > sqrt (-1) :: Double
21:51 <iqubic> That works??
21:51 <lambdabot> NaN
21:51 <c_wraith> more like..
21:51 <Cale> ^^ NaN still isn't bottom
21:51 <c_wraith> > let x = x in x
21:51 <lambdabot> mueval-core: Time limit exceeded
21:51 <Cale> yeah, more like that one ^^
21:52 <Cale> Or undefined, or error "foo!"
21:52 <iqubic> > error "foo!"
21:52 <lambdabot> *Exception: foo!
21:52 <monochrom> I prefer the informational view. Insufficient data for a meaningful answer.
21:52 <Cale> > fix error
21:52 <lambdabot> "*Exception: *Exception: *Exception: *Exception: *Exception: *Exception: *Ex...
21:52 <iqubic> How does error handling work in haskell?
21:52 <iqubic> :t fix
21:52 <lambdabot> (a -> a) -> a
21:52 <geekosaur> iqubic, note with the one that failed on you that negative numeric literals are an odd corner case; it's safest to use parentheses
21:52 hiratara joined
21:53 <iqubic> > sqrt (-1)
21:53 <lambdabot> NaN
21:53 <geekosaur> there's also the NumericLiterals extension which changes things to behave a little more like expected... unless what you expect is IEEE negative zero to work >.>
21:53 <iqubic> What does fix do?
21:53 <boxscape> huh, fix error is interesting
21:53 <Cale> iqubic: Well, exceptions thrown from the evaluation of expressions can technically be caught, but pragmatically, I would always avoid it, to the extent that I would be willing to fork someone's library before bothering with it.
21:53 <boxscape> @src fix
21:53 <lambdabot> fix f = let x = f x in x
21:53 <boxscape> ^ iqubic
21:53 <iqubic> > fix (\x -> x^2
21:53 <lambdabot> <hint>:1:15: error:
21:53 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
21:53 <c_wraith> > negate 0 :: Double
21:53 <iqubic> > fix (\x -> x^2)
21:53 <lambdabot> -0.0
21:53 <lambdabot> mueval-core: Time limit exceeded
21:54 <iqubic> Why doesn't my fix operation work?
21:54 <iqubic> > fix (\x -> x^2)
21:54 <lambdabot> mueval-core: Time limit exceeded
21:54 <Cale> It does
21:54 <boxscape> iqubic: this is a good read on fix: https://en.wikibooks.org/wiki/Haskell/Fix_and_recursion
21:54 <geekosaur> iqubic, it finds the least fixed point of an expression. of ten that is bottom/nontermination, but if an expression converges to a non-bottom constant value then fix will find that
21:54 <Cale> fix will compute the least-defined fixed point of a given function
21:54 <geekosaur> generally
21:54 <Cale> If bottom happens to be a fixed point of the function, that's what you will get
21:55 <Cale> i.e. if the function f gives a totally-undefined result for a totally-undefined input, then fix f will be totally undefined
21:55 <iqubic> geekosaur: Shouldn't 1^2 = 1 work though?
21:55 <Cale> iqubic: That's not the *least-defined* fixed point
21:55 <iqubic> > fix (\x -> false && x)
21:55 <lambdabot> error:
21:55 <lambdabot> • Variable not in scope: false :: Bool
21:55 <lambdabot> • Perhaps you meant data constructor ‘False’ (imported from Data.Bool)
21:56 <iqubic> > fix (\x -> False && x)
21:56 <lambdabot> False
21:56 <geekosaur> iqubic, you need to understand what least-defined means
21:56 <iqubic> What does it mean?
21:56 xmonader3 joined
21:56 <Cale> Well, the ordering is defined separately for each type
21:56 <geekosaur> the least defined fixed point there is bottom, the non-value. 1 is a fixed point but it is more defined than bottom, so it is not found and bottom is
21:56 <fotonzade> okay so what should I use to get an element of a list by index
21:56 <fotonzade> like the 4th element of an array
21:56 <Cale> But generally, x <= y whenever one can substitute occurrences of _|_ (bottom) in x somehow in order to obtain y
21:56 <fotonzade> if not !!
21:57 <geekosaur> fotonzade, you use a Vector if you want to do that, generallyt
21:57 <fotonzade> :(
21:57 <c_wraith> fotonzade: you generally try to avoid needing to do that.
21:57 <geekosaur> the problem is not (!!) itself. the problem is lists are not arrays/vector
21:57 <geekosaur> lists are linked lists
21:57 <geekosaur> you have to iterate them to find the Nth element
21:57 <Cale> iqubic: For example, if we consider the type [Bool]
21:57 <iqubic> > fix reverse
21:57 <Cale> iqubic: You have _|_ at the bottom
21:57 <lambdabot> mueval-core: Time limit exceeded
21:57 <geekosaur> if you;re going to be indexing a lot, lists are not your friend
21:57 <boxscape> > error (error "x") -- I would expect this to print just one exception. Is this really counter intuitive or is it me?
21:57 <lambdabot> *Exception: *Exception: x
21:57 <Cale> and then immediately above that are [] and (_|_ : _|_)
21:57 <boxscape> Actually
21:58 <boxscape> I think I understand
21:58 <monochrom> The fun begins when you say "sometimes I need to append things, some other times I need the ith item"
21:58 <fotonzade> I'm getting this error in my code
21:58 <fotonzade> voting: Prelude.!!: index too large
21:58 <fotonzade> how do I find where in the code it happnes?
21:58 <Cale> and then above (_|_ : _|_) lies (False : _|_) and (True : _|_) and (_|_ : []) and (_|_ : (_|_ : _|_))
21:59 <Cale> This ordering is directed-complete, in that any infinite ascending chain will have a limit in [Bool]
21:59 <iqubic> > fix (\rec n -> if n == 0 then 1 else n * rec (n-1)) 5
21:59 <lambdabot> 120
21:59 <iqubic> what the heck is that???
21:59 <c_wraith> boxscape: technically, GHC is allowed to treat any bottom values as equivalent and optimize things out if it desires. So when you have situations with nested exceptions like that, it's allowed to compile the code such that any of the contained exceptions are the ones that bubble out.
21:59 <Theophane> j #R
21:59 <Theophane> wooops
21:59 <geekosaur> fotonzade, you can try throwing a HasCallstack constraint on any function that uses (!!)
22:00 <boxscape> c_wraith: I see
22:00 <geekosaur> sadly the default is not to use call stacks because (a) they;re not, really (b) they're slow, because they're not really call stacks
22:00 <Cale> iqubic: fix f = x where x = f x
22:00 <sophiag> > (reverse . map (\x -> x -y)) . (map (\x -> y + x) . reverse)
22:00 <lambdabot> <[Expr] -> [Expr]>
22:00 <geekosaur> what it really does is attach a big implicit parameter to everything carrying around its history
22:00 <iqubic> > fix (\rec f l -> if null l then [] else f (head l) : rec f (tail l)) (+1) [1..3]
22:00 <Cale> iqubic: So, if we have x = (\rec n -> if n == 0 then 1 else n * rec (n-1)) x
22:01 <lambdabot> [2,3,4]
22:01 <hpc> iqubic: or somewhat easier to understand, fix f = f (fix f)
22:01 isenmann joined
22:01 <hpc> but cale's definition is faster
22:01 <hpc> well, "faster"
22:01 <iqubic> > fix (\rec f l -> if null l then [] else f (head l) : rec f (tail l)) (+1) [1..3]
22:01 <lambdabot> [2,3,4]
22:01 <Cale> iqubic: then x = \n -> if n == 0 then 1 else n * x (n-1)
22:01 <sophiag> hmm, not sure what the answer to that means. i guess lambdabot is morally correct
22:01 MP2E joined
22:02 <iqubic> > map (fix (\rec n -> if n == 1 || n == 2 then 1 else rec (n-1) + rec (n-2))) [1..10]
22:02 <lambdabot> [1,1,2,3,5,8,13,21,34,55]
22:02 <c_wraith> sophiag: it means lambdabot current has a Show instance for functions in scope.
22:02 <Cale> iqubic: Generally, you can take any simply recursive function, and encode it using fix by making the function itself the first argument to the lambda you supply to fix
22:02 <boxscape> > split
22:02 <lambdabot> error:
22:02 <lambdabot> • No instance for (Typeable a0)
22:02 <lambdabot> arising from a use of ‘show_M78839445066777044367275’
22:02 <iqubic> Ah.
22:02 <fotonzade> http://paste2.org/vNz3N1Ny
22:02 <boxscape> not for functions in general though
22:02 mjz19910 joined
22:02 <boxscape> it seems
22:02 <monochrom> @type split
22:02 <fotonzade> I am completely stumped as to where this !! problem could be happening
22:02 <lambdabot> Splitter a -> [a] -> [[a]]
22:02 <sophiag> c_wraith: i know. i was just seeing what would happen as that's the most common example of having to deal with bottom in lazy languages
22:02 <fotonzade> if you guys can spot it instantly could you help me out
22:03 <c_wraith> > fix $ (0:) . scanl (+) 1 -- iqubic or even recursive non-functions
22:03 <lambdabot> [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,...
22:03 <MarcelineVQ> :t y
22:03 <lambdabot> Expr
22:03 <Cale> sophiag: also, note that lambdabot has x and y in scope
22:03 <Cale> > x
22:03 <lambdabot> x
22:03 <Cale> :t x
22:03 <lambdabot> Expr
22:03 <sophiag> oh
22:03 <MarcelineVQ> sophiag: idk it it was intentional but y isn't in scope in your expression, so lambdabot is using the y it does have in scope which is an Expr
22:04 <sophiag> i wasn't sure what i expected it to return anyway
22:04 <sophiag> id?
22:04 <sophiag> error?
22:04 <iqubic> Can I get someone to explain Prisms weird type synonym?
22:04 <monochrom> fotonzade: In getByNum, "x !! id-1"? "x !! (id-1)"?
22:04 sigmundv joined
22:04 <iqubic> type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t)
22:05 <iqubic> I don't get that.
22:05 <sophiag> iqubic: since you keep asking about optics i'm wondering if there's interest in going through an example of refactoring code to use lenses and prisms? (being clear that it would be a first for me as well)
22:05 <iqubic> But more specifically I don't understand this: prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b Source #
22:05 ericmathison joined
22:05 <iqubic> ignore the Source # there
22:05 <fotonzade> <monochrom> fotonzade: In getByNum, "x !! id-1"? "x !! (id-1)"?
22:06 <fotonzade> let me check this out
22:06 <fotonzade> thank you
22:06 <iqubic> why does it have Either as the return type of the second input function?
22:06 <iqubic> I don't understand that at all.
22:06 <Cale> iqubic: Because you might not find the thing of type a
22:06 <c_wraith> iqubic: because a prism is not a complete isomorphism. It can fail in one direction
22:06 <Tuplanolla> Man, it took almost two hours to compile Hakyll...
22:07 <iqubic> Yes, but why is there an Either data type?
22:07 <iqubic> I don't get that.
22:07 <Cale> iqubic: So in the case where the prism fails to get your thing of type a, you're still going to have to produce something of type t in the end.
22:07 mjz19910 joined
22:07 ericmathison left
22:08 isenmann joined
22:08 <Cale> So, it just makes you provide an Either t a, with the final result being the Left case of the Either.
22:08 <iqubic> So going from B to T always works.
22:09 <iqubic> however going from S to A might fail?
22:09 mjz19910 joined
22:09 <c_wraith> yes
22:10 <c_wraith> and if it fails, you need to give a fallback value.
22:10 <Cale> iqubic: You can read the Prism definition above as
22:10 <Cale> type Prism s t a b = forall f. (Applicative f) => (a -> f b) -> (s -> f t)
22:10 wroathe joined
22:10 <Cale> i.e. so it's the same as Traversal
22:10 <iqubic> How might someone write a prism into a Maybe?
22:10 ublubu joined
22:11 <iqubic> toMaybe = Just
22:11 <iqubic> fromMaybe x
22:11 <iqubic> | Just x = x
22:11 <iqubic> | Otherwise = Nothing
22:12 <iqubic> prism toMaybe fromMaybe
22:12 <iqubic> Is that right?
22:12 <c_wraith> the basic idea is right, the syntax is... in need of help. :)
22:12 <iqubic> Why is the syntax wrong?
22:12 xmonader3 joined
22:12 edmundsecho joined
22:12 mjz19910 joined
22:13 <Cale> _Just = prism Just (maybe (Left Nothing) Right)
22:13 <c_wraith> also, you need an Either in the other case, so you need a Left or RIght constructor
22:13 <iqubic> Why do you need an Either?
22:13 <iqubic> isn't _Just a Prism'?
22:13 <Cale> yes, I just defined it
22:14 <iqubic> So why do you need an Either?
22:14 <* sophiag> is still serious about offering a practical case to refactor code with lenses and prisms...
22:14 <Cale> hm?
22:14 <glguy> :t matching _Just
22:14 <lambdabot> Maybe a -> Either (Maybe b) a
22:14 jao joined
22:15 <glguy> In the case that _Just doesn't "match", it can change the type of its argument
22:15 <iqubic> Oh.
22:16 <iqubic> Why do you need an Either.
22:16 mjz19910 joined
22:16 <c_wraith> iqubic: because that's what prism requires?
22:16 <c_wraith> iqubic: also, because otherwise the two cases don't return the same type
22:17 <Cale> :t prism
22:17 <lambdabot> (Applicative f, Choice p) => (b -> t) -> (s -> Either t a) -> p a (f b) -> p s (f t)
22:17 <Cale> ^^
22:17 <c_wraith> sadly, the location of those carets depends on how you have things aligned. :)
22:17 <iqubic> Why is _Just a Prism and not a Prism'?
22:18 mjz19910 joined
22:18 <c_wraith> :t _Just
22:18 soniku joined
22:18 <lambdabot> (Applicative f, Choice p) => p a (f b) -> p (Maybe a) (f (Maybe b))
22:18 <Cale> _Just :: Prism (Maybe a) (Maybe b) a b
22:18 wroathe joined
22:18 <iqubic> What does that even mean?
22:18 binaryplease joined
22:18 ExcelTronic joined
22:18 <Cale> If it were Prism (Maybe a) (Maybe a) a a then we could use Prism' (Maybe a) a
22:18 ebzzry joined
22:19 <Cale> But it's allowed to change the type of the Maybe which is being traversed
22:19 <iqubic> Why is it not Prism (Maybe a) (Maybe a)?
22:19 <iqubic> How does it do that??
22:19 <Cale> > over _Just show (Just 5)
22:19 <lambdabot> Just "5"
22:19 Theophane left
22:19 <Cale> > over _Just show Nothing
22:19 <lambdabot> Nothing
22:20 <iqubic> I don't get it.
22:20 <Cale> > _Just (\x -> Identity (show x)) (Just 5)
22:20 <lambdabot> Identity (Just "5")
22:20 <Cale> > runIdentity (_Just (\x -> Identity (show x)) (Just 5))
22:20 <lambdabot> Just "5"
22:20 <iqubic> What is that doing?
22:20 <c_wraith> You can use _Just to "change" the type of an expression.
22:20 <Cale> It's a traversal
22:20 <c_wraith> That's why it has different type variables
22:20 <Cale> In the usual sense
22:21 <Cale> There is a difference between _Just and traverse though.
22:22 <Cale> :t traverse :: Applicative f => (a -> f b) -> Maybe a -> f (Maybe b)
22:22 <lambdabot> Applicative f => (a -> f b) -> Maybe a -> f (Maybe b)
22:22 <Cale> :t _Just :: Applicative f => (a -> f b) -> Maybe a -> f (Maybe b)
22:22 <lambdabot> Applicative f => (a -> f b) -> Maybe a -> f (Maybe b)
22:22 <Cale> even though they can have the same type
22:23 oisdk joined
22:23 <iqubic> Can you show me an example of changing the type?
22:23 <Cale> I just did
22:23 <Cale> using show
22:23 <Cale> We turned the 5 :: Integer into "5" :: String
22:23 bhiliyam joined
22:23 <glguy> over _Just show :: Maybe Integer -> Maybe String
22:24 jgt1 joined
22:24 <Cale> The difference between _Just and traverse is that since _Just is a prism, we can "turn it around" with re/review
22:25 <Cale> :t re _Just
22:25 <lambdabot> (Functor f, Contravariant f) => (Maybe a -> f (Maybe a)) -> a -> f a
22:25 peterbec` joined
22:25 <c_wraith> :t review _Just
22:25 <lambdabot> MonadReader a m => m (Maybe a)
22:25 <c_wraith> hah. I forgot that uses MonadReader for maximal surprise.
22:26 <Cale> haha
22:26 <c_wraith> > review _Just 5
22:26 <lambdabot> Just 5
22:26 <Cale> This stuff, man
22:26 <iqubic> is that turning a into Maybe a?
22:26 <c_wraith> yes
22:27 <iqubic> And is that why you need Either?
22:27 <Cale> Just to be clear, I *strongly* avoid lens in actual code unless there's really a good case for it.
22:27 <Cale> There are some cases where you're modifying some deeply nested field, and lens saves you a bunch of trouble
22:27 <iqubic> What's the definition of _Just again?
22:27 <Cale> But a lot of the time, lens is a great way to get trivial things done in an incomprehensible way
22:28 <Cale> _Just = prism Just (maybe (Left Nothing) Right)
22:28 <sophiag> Cale, you strongly avoid lenses? i'm debating right now whether to refactor my code with them...and i don't actually have nested records, just types that have turned into spaghetti
22:29 <boxscape> I like Lens with the State Monad. Though admittedly I haven't done much with it
22:29 <monochrom> My greatest (and only one) application of lens (just the idea anyway) so far is unifying two branches of the rotation algorithm for binary search trees.
22:29 Noldorin joined
22:30 <Cale> There are a bunch of things in the lens toolkit which I still sometimes make use of
22:30 <iqubic> :t maybe
22:30 <Cale> I use zoom
22:30 <lambdabot> b -> (a -> b) -> Maybe a -> b
22:30 <sophiag> monochrom, that's pretty interesting.
22:30 <iqubic> What does maybe do?
22:30 <c_wraith> maybe is a destructor for Maybe values
22:30 <Cale> maybe nothing just = g where g Nothing = nothing; g (Just x) = just x
22:30 <c_wraith> it captures the entire logic of a pattern-match
22:30 <iqubic> I see.
22:31 <monochrom> in which you have one version for rotate-left and one version for rotate-right and they are exact mirror images of each other and you wonder "can I just plug in a parameter to request the left or right version?"
22:31 <EvanR> its kind of *the* destructor for Maybe, since you can do any other destructor with it
22:31 hiratara joined
22:31 <sophiag> hmm
22:31 <monochrom> It turns out that it looks best with two parameters, not just one.
22:31 <sophiag> monochrom: that makes sense. do you have that code somewhere i can look at?
22:31 mjz19910 joined
22:31 <iqubic> > maybe False odd (Just 2)
22:32 <lambdabot> False
22:32 <iqubic> I see.
22:32 <iqubic> > maybe False odd (Nothing)
22:32 <lambdabot> False
22:32 <monochrom> You say "rotate (the lens for left child) (the lens for right child)" for one direction, "rotate (the lens for right child) (the lens for left child)" for the other direction.
22:32 <Cale> maybe (Left ()) Right (Just 4)
22:32 <Cale> > maybe (Left ()) Right (Just 4)
22:32 <lambdabot> Right 4
22:32 <Cale> > maybe (Left ()) Right Nothing
22:32 <lambdabot> Left ()
22:32 dan_f joined
22:32 <iqubic> :t maybe (Left Nothing) Right
22:32 <lambdabot> Maybe b -> Either (Maybe a) b
22:33 <monochrom> I don't have it handy right now.
22:33 <iqubic> What does that function do?
22:33 <sophiag> so basically instead of using a zipper you're treating the entire tree like a product type?
22:33 mjz19910 joined
22:33 <iqubic> I was not aware that Right was a function.
22:33 <EvanR> often you can tell what a function does just from the type sig
22:33 <boxscape> :t Right
22:33 <lambdabot> b -> Either a b
22:33 <iqubic> I see.
22:34 <boxscape> iqubic: any data constructor that takes arguments is a function
22:34 <iqubic> Ah. I see.
22:34 <iqubic> :t (:+)
22:34 <lambdabot> a -> a -> Complex a
22:34 <monochrom> Yes, I am ignoring the Leaf case. (It is OK because by the time you decide to rotate, you already know it is not Leaf.)
22:34 <sophiag> that's kind of awesome
22:35 mjz19910 joined
22:36 unyu joined
22:36 <sophiag> i'm just debating whether to use lenses to eliminate all these crufty helper functions for wrapping and unwrapping types, but probably need to at least try and simplify the types altogether first
22:36 a3Dman joined
22:37 mjz19910 joined
22:37 <iqubic> So why isn't _Just a Prism'?
22:37 <sophiag> i feel like i've come up against something like a second learning curve with haskell where my programs are starting to get slightly too complex for the way i'm structuring the types in them
22:37 <iqubic> Can I see an example of a Prism'?
22:38 <Cale> Prism' a t is just shorthand for Prism a a t t
22:38 <boxscape> :t _Right :: Prism' (Either c1 t1) t1
22:38 <lambdabot> (Applicative f, Choice p) => p t1 (f t1) -> p (Either c1 t1) (f (Either c1 t1))
22:38 <Cale> er, that was backward, convention-wise
22:38 <Cale> type Prism' s a = Prism s s a a
22:39 mjz19910 joined
22:39 <iqubic> Why is _Right a Prism'?
22:39 <iqubic> Can I see how you'd write _Right?
22:39 <Cale> :t _Just :: Prism' (Maybe a) a
22:39 <lambdabot> (Applicative f, Choice p) => p a (f a) -> p (Maybe a) (f (Maybe a))
22:39 <Cale> _Just *can* be a Prism'
22:39 <Cale> It's just that it's more general than that
22:39 <Cale> :t _Right
22:40 <lambdabot> (Applicative f, Choice p) => p a (f b) -> p (Either c a) (f (Either c b))
22:40 <Cale> Same goes for _Right
22:40 <iqubic> How would one write _Right?
22:40 <Cale> Click its source link
22:40 mjz19910 joined
22:40 splanch joined
22:41 <Cale> on any of the documentation pages, in the right margin, you'll see # Source on every definition
22:41 <iqubic> Cool.
22:41 <boxscape> you can also search for _Right using hayoo, which might get you there faster
22:41 <Cale> The # is a link to that part of the documentation (so you can share it), and the Source link goes to highlighted, hyperlinked source.
22:41 bollu joined
22:41 <Cale> (note, different packages will differ in these features, but lens is good about it)
22:42 ali_bush joined
22:43 <SolitaryCypher> I'm reading the Parsec paper and have a quick question. It mentions XML requires a context-sensitive parser, but I thought that XML was a context-free langauge?
22:43 splanch_ joined
22:43 <SolitaryCypher> Oh wait I got it. Brackets are context free because they don't have labels. The labels require context. Nevermind
22:45 <unyu> SolitaryCypher: If you have only finitely many possible tags, the language becomes context-free again, me thinks.
22:46 oberstein joined
22:46 <unyu> s/tags/labels/
22:47 raichoo joined
22:50 <monochrom> Yes, it's just like having 3 kinds of parentheses, [] () {}
22:51 <Cale> I'm not sure about that though, since there's more to XML than just the tags.
22:51 <unyu> Anyway, now on to my actual question. I'm taking a survival analysis class, where we use R, but I want to use Haskell instead. I don't expect there to be many survival analysis libraries in Hackage, but I could implement my own if there are *good* numerical method implementations available - I shouldn't have to debug my programs only to find an error in the numerical method I'm calling.
22:52 <unyu> What's the state of numerical methods in Haskell today?
22:52 <Cale> unyu: There are various bits and pieces. hmatrix is a binding to a bunch of BLAS/LAPACK stuff.
22:53 <unyu> What about compile-time dimensional analysis?
22:53 oberstein joined
22:53 <bollu> what's "survival analysis?"
22:53 <unyu> R's handling of multidimensional arrays is... well... atrocious.
22:53 conal joined
22:53 <Cale> unyu: I know various people have done stuff for that, but I'm not sure what's usable
22:54 <monochrom> main = do <curry> print <round> head <square> 1, 2, 3 </square> </round> </curry>
22:54 <unyu> bollu: Inferential statistics, where the variable of interest is “time until X happens”. That time could be any nonnegative real number, but in practice, you can't wait infinite time until X happens. Or for whatever reason, one of your study subjects becomes impossible to observe after a point in time. So you need to deal with incomplete (statisticians call this “censored”) data.
22:55 <unyu> Cale: Ah!
22:55 <bollu> ah, that is interesting
22:55 <unyu> Yes, but R is incredibly frustrating to use.
22:56 <EvanR> its interesting to hear doubts about R and looking at haskell
22:57 tomboy64 joined
22:59 joneshf-laptop joined
23:01 <MarcelineVQ> what is meant by compile-time dimensional analysis?
23:01 <EvanR> unit checking?
23:01 ziarkaen joined
23:02 <EvanR> unit conversion?
23:02 <unyu> Errr, I'm not so interested in units of measure. I'm mainly interested in matrix dimensions.
23:02 <EvanR> matrix dimensions
23:02 <MarcelineVQ> ah hmm well you can enforce dimentions at compile-time with hmatrix through https://hackage.haskell.org/package/hmatrix-
23:02 <unyu> Oh, sweet! Checking.
23:02 <MarcelineVQ> jle` has a couple posts on it at https://blog.jle.im/entry/practical-dependent-types-in-haskell-1.html https://blog.jle.im/entry/practical-dependent-types-in-haskell-2.html
23:02 <iqubic> > review _Just "Hello"
23:02 <lambdabot> Just "Hello"
23:02 <iqubic> > preview _Just Nothing
23:02 <lambdabot> Nothing
23:03 <MarcelineVQ> It's evolving ground for Haskell though so there's a bit to learn to get going
23:03 <iqubic> > preview _Just Just "Hello"
23:03 <lambdabot> error:
23:03 <lambdabot> • Couldn't match type ‘Maybe b0’ with ‘[Char] -> t’
23:03 <lambdabot> Expected type: (a0 -> Maybe a0) -> [Char] -> t
23:03 <iqubic> > preview _Just (Just "Hello")
23:03 <lambdabot> Just "Hello"
23:03 <iqubic> :t Preview
23:03 <lambdabot> error:
23:03 <lambdabot> • Data constructor not in scope: Preview
23:03 <lambdabot> • Perhaps you meant one of these:
23:04 <iqubic> :t preview
23:04 <lambdabot> MonadReader s m => Getting (First a) s a -> m (Maybe a)
23:04 <iqubic> :t review
23:04 <lambdabot> MonadReader b m => AReview t b -> m t
23:04 <c_wraith> > preview _Just (Nothing)
23:04 <unyu> I'd be happy if the compiler can keep track of how many indices a particular array has. I don't mind if the exact sizes of matrices are checked at runtime.
23:04 <lambdabot> Nothing
23:04 revprez_atlanta joined
23:05 <EvanR> unyu: isnt that the exact opposite expectations
23:05 <unyu> EvanR: Opposite to what?
23:05 <EvanR> tracking at compile time would obviously be better
23:05 <EvanR> than runtime
23:06 ChaiTRex joined
23:06 <EvanR> so either i misunderstand or it doesnt really matter what it does
23:06 <unyu> EvanR: What I'm saying is that there are two things to track: (0) how many indices an array has, (1) how many possible values does each index have.
23:06 <EvanR> oh
23:06 <unyu> I absolutely want (0) to be statically checked, but don't mind if (1) is dynamically checked.
23:06 <EvanR> 3d vs 4d vs whateverd array
23:06 <unyu> Yeah.
23:07 <EvanR> "how many indexes it has" confused me. i think they call that the shape
23:07 <unyu> Ah...
23:07 markus1209 joined
23:08 markus1219 joined
23:09 <iqubic> How does this work? maybe (Left Nothing) Right
23:11 msks joined
23:11 <unyu> Mmm, maybe you want Left (), rather than Left Nothing?
23:11 <MarcelineVQ> iqubic: ask ghci about the types
23:11 takle_ joined
23:11 theDon_ joined
23:12 <glguy> iqubic: What kind of answer are you hoping to get to that question?
23:12 <iqubic> unyu: That's exactly what I want.
23:12 <unyu> iqubic: Substituting into the definition of “maybe”, you should get something like “\x -> case x of { Just x -> Right x ; Nothing -> Left () }”
23:12 <iqubic> Ah, I see.
23:13 <iqubic> @src maybe
23:13 <lambdabot> maybe n _ Nothing = n
23:13 <lambdabot> maybe _ f (Just x) = f x
23:13 <iqubic> I see how that works now.
23:13 <iqubic> Cool.
23:13 <unyu> :-)
23:15 falafel joined
23:17 fakenerd_ joined
23:18 e14 joined
23:19 mstruebing joined
23:19 blender joined
23:20 augur joined
23:21 <iqubic> @src ($)
23:21 <lambdabot> f $ x = f x
23:21 <iqubic> I see
23:22 connrs joined
23:23 aarvar joined
23:23 cpup joined
23:26 peterbec` joined
23:31 richi235 joined
23:33 <sleffy> Is there a reason that there appears to be no Random instance for Natural?
23:34 <EvanR> the api has a thing for uniformly random value of the type
23:34 <EvanR> which is fudged for Double by only going from 0.0 to 1.0
23:34 danthemyth joined
23:35 <EvanR> you can only get a random Natural by using a non uniform distribution
23:36 augur joined
23:36 <EvanR> also Natural is relatively new on the scene and isnt recognized by many old guard libs
23:37 lambda-11235 joined
23:39 CoderPuppy joined
23:40 splanch joined
23:41 <EvanR> experiment: if you start at 0, flip a coin, heads return 0, otherwise increment the counter and try again... you get an exponential decay distribution.
23:41 <EvanR> next, do it again rolling 1d4 and only return the counter if you get a 1
23:41 <unyu> How's Natural internally implemented? Is it a big unsigned int?
23:42 <EvanR> next, keep increasing the sides of the dice, your random Naturals will become bigger and bigger as it takes longer to return an answer
23:42 <EvanR> in the limit, the random Natural will be infinite and the algorithm "probably" never terminates
23:43 <EvanR> Natural is just an Integer that errors on negative
23:43 <unyu> Ah.
23:43 <EvanR> > (-1) :: Natural
23:43 <lambdabot> *Exception: Natural: (-)
23:43 <EvanR> hmm
23:43 wroathe joined
23:43 <EvanR> > fromInteger (-1) :: Natural
23:43 <lambdabot> *Exception: Natural: fromInteger
23:43 leat joined
23:44 meba joined
23:46 <MarcelineVQ> :t fromInteger . abs <$> getRandom :: m Natural
23:46 <lambdabot> error:
23:46 <lambdabot> Variable not in scope: getRandom :: m1 Integer
23:46 <MarcelineVQ> :t fromInteger . abs <$> getRandom -- oops don't need the last bit :>
23:46 <lambdabot> error:
23:46 <lambdabot> Variable not in scope: getRandom :: f Integer
23:46 watabou joined
23:46 <MarcelineVQ> oh, well there's that too, nvm me
23:47 augur joined
23:49 hoknamahn joined
23:49 <EvanR> actually, if you truncate that experiment at some very large dice size, youll get a working algorithm, though very slow and numbers will be huge
23:50 <EvanR> and kind of uniform
23:51 <EvanR> the difference in probability between n1 and n2 near each other is low
23:51 a3Dman joined
23:51 justanotheruser joined
23:51 <monochrom> Integer is a Random instance and it is a bit mysterious which distribution it follows.
23:51 msks joined
23:52 <monochrom> But whatever it does, Natural could suffer the same fate.
23:52 <EvanR> uniform in the range 0 to max int
23:53 mizu_no_oto joined
23:53 <MarcelineVQ> you can pick distributions with random-fu but I don't know enough about distributions to try
23:53 wroathe joined
23:53 <monochrom> Actually the range is min Int to max Int
23:55 <monochrom> Also I just learned that "Ival" is a cool way to spell "Interval"
23:55 YongJoon joined
23:55 <EvanR> oh
23:56 fotonzade joined
23:57 <monochrom> do { ct <- getCPUTime; (sec, psec) <- getTime; return (createStdGen (sec * 12345 + psec + ct + o)) }
23:57 <monochrom> Studies show that there was no studies to support the choice of multiplying by 12345 there. :)