|
1337JiveTurkey posted:Optional types feel half-assed when mixed with parametric polymorphism because while Foo[T] and Foo[Option[T]] may look closely related, they're nothing alike. Any situation where a method could return an Option[T], it should be equally valid to return a T rather than a Some[T]. So if T is covariant with Foo, then Foo[T] should be a subtype of Foo[Option[T]]. But if you want that in Scala for instance, then it needs to be Foo[Some[T]] which seems a tad ridiculous in terms of overhead when I want to use a Foo that always returns a T in a situation that calls for a Foo that may return a T without some sort of shim. This is nonsense. T is not and should not be covariant on a context F whether it's Foo[T], Foo[Option[T]], or Option[T]. They all have significantly different meanings. e: s/contravariant/covariant but really any variance. sink fucked around with this message at 01:54 on Jul 8, 2015 |
# ? Jul 7, 2015 19:50 |
|
|
# ? Jun 6, 2024 08:17 |
|
1337JiveTurkey posted:Optional types feel half-assed when mixed with parametric polymorphism because while Foo[T] and Foo[Option[T]] may look closely related, they're nothing alike. Any situation where a method could return an Option[T], it should be equally valid to return a T rather than a Some[T]. So if T is covariant with Foo, then Foo[T] should be a subtype of Foo[Option[T]]. But if you want that in Scala for instance, then it needs to be Foo[Some[T]] which seems a tad ridiculous in terms of overhead when I want to use a Foo that always returns a T in a situation that calls for a Foo that may return a T without some sort of shim.
|
# ? Jul 7, 2015 20:04 |
|
Bret Hart on null https://www.youtube.com/watch?v=QgwTm1P37l4
|
# ? Jul 8, 2015 00:47 |
|
Volte posted:If Foo[T] is a subtype of Foo[Option[T]] then Option[T] is a subtype of Option[Option[T]] and the whole universe implodes This is from my phone while I wait to get pizza, but isn't that just an implicit conversion via join :: (Monad m) => m (m a) -> m a? I mean, I guess you could make an Option[T] that didn't follow monad laws, but I'm pretty sure you'd have to a ctively try.
|
# ? Jul 8, 2015 02:28 |
|
Or duplicate : (Comonad w) => w a -> w (w a), whichever way you need to go. Seems perfectly fine.
|
# ? Jul 8, 2015 03:14 |
|
code:
|
# ? Jul 8, 2015 03:29 |
|
Sinestro posted:This is from my phone while I wait to get pizza, but isn't that just an implicit conversion via join :: (Monad m) => m (m a) -> m a? I mean, I guess you could make an Option[T] that didn't follow monad laws, but I'm pretty sure you'd have to a ctively try.
|
# ? Jul 8, 2015 10:35 |
|
Steve French posted:How do you reconcile this at runtime, though? If you have something that depends on a Foo[Option[T]] returning Option[T], and you give it a Foo[T] returning T, what happens when you use that Foo and expect an Option[T] and call map on it, but instead you've been given a T? Does the compiler actually make your Foo[T] into a Foo[Option[T]] for you and wrap all your T instances with Some for you? Not saying this is intractable, just intrigued and wondering how you think it would work out in practice. Sorry for the delay. At runtime it should be really simple since I'd treat None as a null reference, Some[T] as a non-null reference and Option[T] as a possibly null reference. So a method returning an Option[T] would be returning a plain old reference to T that's possibly null while a method returning Some[T] or just T would return a plain old non-null reference to T. Every T is an Option[T] but not every Option[T] is a T since they can also be None. One consequence is that there's no way to distinguish None and Some[None] at runtime. There's also no way to distinguish T, Some[T] and Some[Some[T]] but I don't think those are meaningful, they're just artifacts of using wrappers. What we want is for Option[T] = T + None but implementations are really Option[T] = Some[T] + None. Programming languages with nullable references actually have T + None, the problem is that they don't have a way to distinguish it from T at compile time. So instead of Option[T], Some[T] and None, I'd go with T, T? and None and make an explicit wrapper Option[T] which provides map etc while T? is just for pattern matching. For the sake of convenience there'd probably need to be some tweaks but ideally everything would use T? and then wrap it when they map it.
|
# ? Jul 8, 2015 17:51 |
|
https://github.com/NyxStudios/TerrariaAPI-Server/blob/general-devel/Terraria/Player.cs#L21444 I know this is mostly decompiled code but
|
# ? Jul 8, 2015 17:59 |
|
1337JiveTurkey posted:Sorry for the delay. At runtime it should be really simple since I'd treat None as a null reference, Some[T] as a non-null reference and Option[T] as a possibly null reference. So a method returning an Option[T] would be returning a plain old reference to T that's possibly null while a method returning Some[T] or just T would return a plain old non-null reference to T. Every T is an Option[T] but not every Option[T] is a T since they can also be None. And you think it's worth all this messing around with your type system just to save 6 characters when someone wants to throw a T into an Option[T]? e: And, as you mention, making it impossible to distinguish between your function failing to return data, and your function succeeding in returning data that happens to be a None from somewhere else. Jeb Bush 2012 fucked around with this message at 18:21 on Jul 8, 2015 |
# ? Jul 8, 2015 18:05 |
|
omeg posted:https://github.com/NyxStudios/TerrariaAPI-Server/blob/general-devel/Terraria/Player.cs#L21444 isn't terraria the game where the server asked the client whether it should have admin privileges and peoples' public servers got demolished on the regular, all land destroyed, people spawn killed i also remember that for a long time, you could effectively DoS the xna-based server .exe by just telnetting to the ip:port repeatedly and use up a player slot, and it would never be freed after you disconnect because you never sent some handshake
|
# ? Jul 8, 2015 18:33 |
|
Terraria, and possibly that very god class has come up before in this thread because it's such a pile of poo poo under the hood.
|
# ? Jul 8, 2015 19:23 |
|
Biowarfare posted:isn't terraria the game where the server asked the client whether it should have admin privileges lmao
|
# ? Jul 8, 2015 19:48 |
|
I'm honestly wondering how they're able to update the game and even add some huge content patches and not break everything.
|
# ? Jul 8, 2015 19:57 |
|
Copy of terraria (2) real.cs.bak
|
# ? Jul 8, 2015 19:58 |
|
Biowarfare posted:Copy of terraria (2) real.cs.bak version control
|
# ? Jul 8, 2015 20:25 |
|
code:
|
# ? Jul 8, 2015 20:33 |
|
John Big Booty posted:
ah, yes, perl, that language notable for lacking any standard built-in way to get the class of an object such as ref() or Scalar::Util::blessed() how fortunate that nobody ever overloads the stringification operator, so this reliable hack can save the day
|
# ? Jul 8, 2015 23:23 |
|
I'm sure the code behind this is unassailable in terms of quality of construction, yet I feel the need to lodge a complaint against gmail in here. Here's part of the body of an email we send, as it appears in the gmail client (desktop version): I blacked out the rest of the paragraph just to leave my company-specific stuff out. Now, in case you haven't had the pleasure, gmail only allows inline styles. linked css, <style> tags, media queries etc. are all eliminated. Also, they will ignore/overwrite certain style elements based on whatever context they decide to do that on, so you have to use "!important" all over the place to hopefully guard against that. Okay, if that was the worst of it I'd be more or less fine with it. I can push back on the design team to say their fancy responsive email templates just won't play nice with gmail. But now take notice in that image the <p> that encapsulates: "hi fred", a couple <br/>'s and then a paragraph of just plain text. Check out that same email when viewed on gmail's site when it detects a mobile user-agent: They completely changed up the html structure and broke it out of its home (which is too nested due to the WYSIWYG used to make these templates, I admit). Oh and to top it all off, that div they added around the br's and paragraph you'll note has class="gi ji". Yep gmail has styles for those: CSS code:
If there's some obvious advantage to all this that I'm not seeing that makes all this totally logical (or if I did something wrong like not add the header FuckWithEmailBody=false) then please let me know. I can totally get clearing js out of email and -some- stylesheet restrictions, but gmail is frustratingly aggressive in its manipulation. Bhaal fucked around with this message at 01:46 on Jul 10, 2015 |
# ? Jul 10, 2015 01:40 |
|
HTML emails are a shitshow all around so the norm is pretty much to just embed as much of your content as possible into an image to avoid it getting mangled (with a "view in browser" link just in case).
|
# ? Jul 10, 2015 15:29 |
|
SupSuper posted:HTML emails are a shitshow all around so the norm is pretty much to just embed as much of your content as possible into an image to avoid it getting mangled (with a "view in browser" link just in case). Yeah, HTML emails are the horror alone. GMail isn't the only thing that has extreme restrictions on what is allowed in an HTML email: eg Outlook only supports a subset of HTML and only inline styles. I'm pretty sure the main reason for it is to reduce surface area for attacks, but lol.
|
# ? Jul 10, 2015 16:17 |
Bhaal posted:I'm sure the code behind this is unassailable in terms of quality of construction, yet I feel the need to lodge a complaint against gmail in here. Oh please. That's got nothing on my old find in Apple Mail.
|
|
# ? Jul 10, 2015 16:19 |
|
The only other foolproof way (I can think of) to prevent malicious HTML email from loving with an HTML UI is to show the email body in an iframe, which I'd guess would make the HTML UI's memory footprint even worse for one thing.
|
# ? Jul 10, 2015 16:22 |
|
Apple's design ethic requires that customer-facing source code is fractal.
|
# ? Jul 10, 2015 16:26 |
|
I'm on my phone now, but there was someone enumerating the geographical features present on that code iirc.
|
# ? Jul 10, 2015 16:43 |
|
that was about the fujifilm website
|
# ? Jul 10, 2015 19:25 |
|
necrotic posted:Yeah, HTML emails are the horror alone. GMail isn't the only thing that has extreme restrictions on what is allowed in an HTML email: eg Outlook only supports a subset of HTML and only inline styles. I'm pretty sure the main reason for it is to reduce surface area for attacks, but lol. I thought they were using the Word layout engine to render the HTML.
|
# ? Jul 11, 2015 19:31 |
|
sarehu posted:The answer is, unsurprisingly, you have to read libraries' API documentation. What's API documentation?
|
# ? Jul 11, 2015 19:57 |
|
Meet Opa, the hot new language that combines every single web technology known to man! With such unique features as:quote:Typechecker: Opa unique feature is its advanced typechecker that automatically verifies your application code, looking for bugs and inconsistencies, and crunching debugging time. Automatically? That's amazing, how do I get in on this wizardry? Let's look at the reference card: code:
code:
code:
code:
code:
code:
|
# ? Jul 11, 2015 23:22 |
#toto
|
|
# ? Jul 11, 2015 23:24 |
|
SupSuper posted:aaaaaaaaaaaaaaaaaaaaaaaaaaa
|
# ? Jul 12, 2015 00:00 |
|
/kansas/residents <--* #toto
|
# ? Jul 12, 2015 00:03 |
|
Volte posted:The funniest part is that the two supported databases are MongoDB and, uh, Dropbox. Coding horrors: the two supported databases are MongoDB and, uh, Dropbox
|
# ? Jul 12, 2015 00:03 |
|
Opa's like four years old and peaked a while ago.
|
# ? Jul 12, 2015 00:08 |
|
That reminds me. I have, in my possession, source code written in an in-house scripting language, which looks like the most insane language known to man-kind. It looks like this:code:
It also looks like this: code:
The "@" seems to be a Lisp-like lambda here, which is always used for function calls or class construction. A way of passing a function call through to another layer. I think it's a neat idea. And it also looks like this: code:
Oh, but of course, that can't only be it. code:
By the way, I don't even think this language has a name. The binary that interprets it is just called "script.dll" and all of the scripts end in ".txt". Suspicious Dish fucked around with this message at 02:26 on Jul 12, 2015 |
# ? Jul 12, 2015 02:24 |
|
Is Opa an abbreviation of Opaka? Never name your proglang after a DS9 character.
|
# ? Jul 12, 2015 03:21 |
|
omeg posted:https://github.com/NyxStudios/TerrariaAPI-Server/blob/general-devel/Terraria/Player.cs#L21444 public bool puppy; Edit: my scrolling thumb is tired and I'm nowhere near the bottom. This class is amazing. Blue Footed Booby fucked around with this message at 13:42 on Jul 12, 2015 |
# ? Jul 12, 2015 13:40 |
|
sarehu posted:Is Opa an abbreviation of Opaka? Never name your proglang after a DS9 character. I thought it was named after the ship from Fantasy Zone.
|
# ? Jul 12, 2015 14:44 |
sarehu posted:Is Opa an abbreviation of Opaka? Never name your proglang after a DS9 character. drat, there goes my router config DSL called Captain Cisco.
|
|
# ? Jul 12, 2015 14:46 |
|
|
# ? Jun 6, 2024 08:17 |
|
sarehu posted:Is Opa an abbreviation of Opaka? Never name your proglang after a DS9 character. Agreed, but also, never call anything a "proglang".
|
# ? Jul 12, 2015 16:42 |