Conversation started Jan 14, 2015 at 15:22.
Jan 14, 2015 15:22
what happened to "OMG haskell so high level"?
@Puppy that's monadstate instance
@Puppy uh what
@R.MartinhoFernandes meh. It compiles. No declaration involved. Just a void expression
@Puppy out of curiosity, what's not high-level in that for you?
Jan 14, 2015 15:24
@R.MartinhoFernandes It's not including any standard library header, though. It was about deconstructing the analysis that "obviously" a declaration was involved, Node and Ptr "obviously" were types/template argument etc.
@EtiennedeMartel Hi, quick question. What do you think about ice cider?
@рытфолд yeah. meh posted that a while ago right
@BartekBanachewicz Getters and setters.
user1804599
Yeah.
Jan 14, 2015 15:25
It's the same concept, only I did it without training wheels :)
@Rerito It's incredibly good.
Next question.
> Certain sets of names and function signatures are always reserved to the implementation:
— Each name that contains a double underscore `__` or begins with an underscore followed by an uppercase letter (§2.12) is reserved to the implementation for any use.
@sehe I don't know where people got this idea that names are only reserved if including headers.
Sparkling or not sparkling?
@Puppy pardon me, but what's the high level equivalent of operating on state then?
@Rerito Not sparkling.
Jan 14, 2015 15:27
@sehe Thank you.. I shall have a look
I'm not a fan of bubbles, usually.
@BartekBanachewicz x.member and x.member = value, clearly.
user1804599
COOPER WHAT ARE YOU DOING
Jan 14, 2015 15:28
I'll let this slide even though it's animated.
what's up with the sparkling bjarne
I never got that
It's fabulous.
user1804599
Sparkly Bjarne is the only allowed GIF.
3
it's ridiculous
@Puppy once you define a monadstate instance, you can use lenses to use that syntax if you wish. Or any other monadic operation that can utilize state.
Jan 14, 2015 15:28
this isn't though:
@martineau If you are concerned about people associating your name with the use of spaces between words, you can always make such answers Community Wikis. — TylerH 1 hour ago
except lenses define assignment as .= but that's of course a minor issue
you mean, "Once you define a whole bunch of getters and setters, you can think about using actual syntax"?
that's super high level, bro.
@LightnessRacesinOrbit You just say that because you're racist.
@Puppy there's no "whole bunch". You define it once, for a particular context.
@рытфолд So classy, so shiny
Jan 14, 2015 15:29
I did it twice to simulate having two contexts from one. (using one in two ways)
the guys with the glitter letters were the first I thought about after seeing the bjarne
doing it once is bad enough.
you should be able to either use the syntax off the bat, or be able to reflect on your data thingie and generate all the getters and setters.
manually enumerating all the stuff and spelling out every getter and setter is C primitive.
user1804599
You can have the getters and setters generated.
fuck yeah this thing compiles
user1804599
It's just $(makeLenses ''T) per type.
user1804599
Jan 14, 2015 15:30
Or something like that.
I was thrown into an alien codebase and a deadline
@Puppy I am not enumerating stuff. It's done once per the context handling state.
I have no idea what goes on around here
but I seem to be doing ok
user1804599
In Scala it's similar: @Lenses case class T(...).
@BartekBanachewicz It seemed to me that you basically enumerated all of the members.
Jan 14, 2015 15:31
@Puppy My data thingie specifically holds some things that I don't wish to expose in that stateful context.
OK WE'RE OUT OF ORBIT
so private: then
@Puppy It. 'There exist rvalues for which…' vs 'For all rvalues…'.
@Puppy there's no concept of "private" in haskell, because once you are given data, you're free to do with it whatever you wish
right, which you are hacking on by only generating some getters and setters, whereas everybody else just has a keyword they use.
Jan 14, 2015 15:33
@Puppy Nah, you don't have to do that. Typically it's just one monadstate instance (that can be automatically derived IIRC). I did it manually because I needed a way to separate user contexts from library contexts
@LucDanton Well, I think that if you say "Rvalues can be assigned to", then I think that implies all rvalues, unless you emphasise "can".
also ugh, I was mislead by the existing code
@Puppy that keyword works in a different way to what I'm doing.
there's this pointer to something that is only valid on the thread it was created on
and I was trying to use it on another thread, since it was nicely cached for me
and I could generate that code using TemplateHaskell of course, but it's hardly a problem to do it manually because it's so scarce
Jan 14, 2015 15:34
turns out they made it global just to avoid passing it as a parameter to their methods -_-
so because lazy
in short, creating contexts like that is way more powerful than simple access specifiers; that's why it can be more verbose
on the bright side, I'm going beyond the call of duty to fix this mess
@Puppy No, they don't...
Jan 14, 2015 15:36
inb4 sacked for not doing the job you were hired to do
I am doing the job, I'm just removing the global crap mess :P
@R.MartinhoFernandes Why do you take the bait after all these years?
@LightnessRacesinOrbit been there... done that
@Mgetz lol
must've been a sucky workplace
here you're free to fix other people's code as long as you explain in an email why you did it
Jan 14, 2015 15:37
@Puppy Random news headline from the Health section: "Patients Seek ‘Right to Try’ New Drugs".
@LightnessRacesinOrbit absolutely, I was managing SCM because nobody else would and got sacked because I couldn't keep up with the dev schedule and keep the builds going
@AlexM. it was horrible, it was a dying company. It had the feel of an execution squad where you're never sure who's going to die next
@LucDanton If there were any new drugs for my condition perhaps I'd want to try them.
@Mgetz gutted
@Mgetz are they still in business?
@AlexM. "Subject: Because you all suck"
@LightnessRacesinOrbit somehow, all the good devs left within 6 months of me getting fired
basically an offshore shop now
the product sucks and crashes a lot
@Puppy That's irresponsible. You are not qualified to decide that drug X is a good one for you, especially if it's new. Then the health system needs to take on the burden of looking after you when it goes horribly wrong.
A "right" to try drug X is insane.
@Mgetz offshore shop, like, a supermarket on a boat?
Jan 14, 2015 15:41
@LightnessRacesinOrbit "Don't work too hard, you'll make us look bad"
@LightnessRacesinOrbit india
5 mins ago, by Lightness Races in Orbit
@R.MartinhoFernandes Why do you take the bait after all these years?
@Mgetz hello sir please kindly review my code attached best regards shamil gupta
3
Jan 14, 2015 15:42
maybe I could help it by defining my instance of AppRuner
if I used TypeFamilies
@R.MartinhoFernandes I didn't, actually. I just said I didn't care for this sample :)
shit. it's getting dark and dangerous
@AlexM. not quite, but you do have a lot of people that don't understand RAII and exception safety... or memory safety
@Mgetz ITT india is "offshore"
@R.MartinhoFernandes Hah! I knew you'd call me out on that!
I'm not using the library state at all and that might be causing the ambiguity
let's try with Int
Jan 14, 2015 15:43
@Puppy Data types in Haskell are either completely opaque or completely transparent, depending on whether you expose the constructors or not. Getters and setters enable selectively exposing certain members without exposing the constructor. They're also easily composable; using patterns and constructors isn't.
are you saying that the accessibility of the members is based on the accessibility of the constructor?
The constructor is the members, in a way.
if you don't have a constructor, you can't pattern match on it
but yeah, the constructor defines what's actually going to be held in the value
consider dunno, data Puppy = Numeric Int | Stringish [String]
Well, I guess you can make a type half-opaque by exposing only a subset of constructors. That'd be rather weird, though.
Doesn't Haskell offer representation-independent pattern matching like Scala does with unapply?
Jan 14, 2015 15:48
I don't think so.
A constructor used is an important part of the value.
discarding that information seems scary, dangerous, and hardly useful
unless
you actually pattern match on it, get the members out and unify operations on all possible constructors
data Mesh =   Mesh { vao :: GL.VertexArrayObject,  vbo :: GL.BufferObject, vertNum :: Int }
            | IndexedMesh { vao :: GL.VertexArrayObject, vbo :: GL.BufferObject, ibo :: GL.BufferObject, vertNum :: Int }

instance Drawable Mesh where
    draw (Mesh _vao buffer n) = UnsafeGlisha $ liftIO $ do ...
    draw (IndexedMesh _vao _vbo _ibo _) = UnsafeGlisha $ liftIO $ do ...
in that case, you can draw mesh and not be concerned whether it's indexed or not.
@FredOverflow There's a pattern synonyms extension that is similar, but no.
personally I don't see what's so special about the constructor
I mean, constructors are important things, but I don't see why it should be the determinant of accessibility for all members.
6 mins ago, by R. Martinho Fernandes
The constructor is the members, in a way.
that simply does not make sense to me
"C++ was built specifically for platform independence and as such is found on every single operating system in existence." <--- Isn't this a false statement?
Jan 14, 2015 15:53
The constructor provides construction and destructuring. There's no other way to access the members. (well, except if you add getters)
@Puppy can you read and understand the example above?
@BartekBanachewicz lol?
@Puppy because in case a function is called within the class, it needs to have defined variables and a constructor does this.
@R.MartinhoFernandes I think it's a good example and I thought there might be something unrelated blocking him in understanding it.
@DonLarynx uh no. it's not equivalent constructors and classes from other languages.
@BartekBanachewicz Somewhat. Are you saying that when you're pattern matching, that actually invokes the constructor?
Jan 14, 2015 15:55
No.
But you can only do it if the constructor is accessible.
pattern matching is reading an existing object.
what the fuck does the constructor have to do with that?
The constructor is matched as well.
It is part of the object.
@Puppy consider data T = A Int | B Int. You're given a value of type T.
a constructor is just a function that produces an object.
there's no reason for an existing object to care in the slightest about how it was constructed.
@Puppy but the objects produced by different constructors aren't equivalent
can't be
Jan 14, 2015 15:58
The constructor is the tag in a tagged union.
well I can see why you might want tagged unions, but making the constructor the tag sounds insane.
actually I've never seen a need for tagged unions but I guess it might be hypothetically useful.
(Almost) Everything is a tagged union in Haskell.
it's extremely useful in practice, actually.
Jan 14, 2015 15:59
@R.MartinhoFernandes Firstly, maybe I'd like untagged unions? Or tagged with something else?
and secondly
@Puppy You can have a data type with just one constructor, and then you're free to implement whatever number of construction functions you want.
the most obvious problem with that is that I find having objects with inaccessible constructors but public getters is fairly useful.
@Puppy "Tagged with something else" doesn't make a lot of sense.
in fact I coded one less than ten minutes ago.
@Puppy and that's where monadstate or monadreader instance comes in
user1804599
Jan 14, 2015 16:00
lol unarguing with puppy about haskell again
@BartekBanachewicz Right, so what you're saying is, "By default, the language does something totally insane, and then maybe later, you can go and fix it up manually"?
@Puppy That's no problem at all... Expose getters, don't expose the constructor.
@BartekBanachewicz That makes no sense.
(not that I'm claiming that manually gettering everything in C# is necessarily so much better)
@Puppy you're assuming that the "insane" thing is what you don't want, and in practice it's actually what you do want.
you're probably still thinking about Haskell data as OOP objects, and they're really not used like those
Jan 14, 2015 16:02
well, it probably helps that I don't care in the slightest about pattern matching.
so the whole constructors-for-pattern-matching thing grants zero desirability for me
user1804599
That's because you've only ever used one programming style and never consider trying something else.
6
@FilipRoséen-refp hail, stranger
@Puppy Pattern matching is the low-level feature to expose a type's internal structure.
@R.MartinhoFernandes I'm perfectly happy with object.member really.
what bringst thou
Jan 14, 2015 16:03
it's direct and to the point.
@Puppy That's what getters do.
right, so burn pattern matching in the Sun and just use getters in the first place.
@AlexM. I've just been offline a lot. I'm still the same old (kinda annoying) prick as before
how do you use Wide's Option type? (or whatever you call it)
Jan 14, 2015 16:05
haven't really decided.
C++'s optional isn't that bad but there are definitely some places where I'd like usage to be easier.
Gotta love how people start trolling really hard once a thread is moved into a board I don't have moderation rights in -.-
assuming you don't have a default value replacement, how do you extract a value from the Option?
for variant I've already decided to bring that into the language so perhaps optional will go the same way
@Puppy okay, and how do you use your variant? Let's say I got a variant as a parameter. How do I act basing on its value?
@Puppy That would impact readability in many scenarios.
Jan 14, 2015 16:06
In computer programming, particularly functional programming and type theory, an algebraic data type is a kind of composite type, i.e. a type formed by combining other types. Two common classes of algebraic type are product types, i.e. tuples and records, and sum types, also called tagged unions or variant types. The values of a product type typically contain several values, called fields. All values of that type have the same combination of field types. The set of all possible values of a product type is the set-theoretical product of the sets of all possible values of its field types. The values...
@R.MartinhoFernandes In a highly positive way.
So Wide will be awesome in each and every aspect. Big whoop.
Oh well, hold on to your ingrained ignorant opinion, then.
@R.MartinhoFernandes ouch.
@BartekBanachewicz At least on the top level, the compiler generates overloads for each type in the variant, so there's no need for you to check what type it has at all.
Jan 14, 2015 16:08
@Puppy overloads of what?
the function accepting the variant.
And how do you write the function's body?
how does it generate them, if their bodies might be different?
as if it were not a variant parameter at all (because it isn't).
Jan 14, 2015 16:09
why is mysql workbench so sexy
I don't get it
@Puppy wait, so your variant actually isn't a variant? what it is then?
if the bodies are different then use overload resolution.
that's what it's for.
So you do pattern matching in the signatures...
not even microsoft seems to get the visual appeal of their tools this good
Jan 14, 2015 16:11
hint: pattern matched functions in haskell look just like overloads (except the type doesn't change)
You know, kinda like pretty much the exact same thing you do in Haskell.
maybe I shouldn't say that, but it's pretty hilarious
well, here's one obvious difference
Yes. Haskell also provides syntax to do it inline.
Jan 14, 2015 16:13
if you have a T, you don't need constructors to match overloads.
You need some way to destructure the variant, and it's going to end up being some kind of check against a type or a tag or whatever. It's silly to claim you don't have one just because you moved it.
@Puppy that's because haskell constructors are also used as a tags, whereas your constructors are just constructor functions, and the tags are stored in the variant
the mechanism is really pretty damn similar
@ÓlafurWaage was it @LightnessRacesinOrbit who wrote that?
@Abyx Probably.
Jan 14, 2015 16:16
and let's not forget that Puppy both claimed he absolutely hates and despises pattern matching and mentioned that he implemented it in Wide not being aware of it
 
Conversation ended Jan 14, 2015 at 16:16.