Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
HoboMan
Nov 4, 2010

now i'm in vs2015 ,vs properly validates the html. and i was again treated to the magic moment when you learn absolutely everything is broken so pervasively you are afraid to fix anything because it might actually break functionality.

Adbot
ADBOT LOVES YOU

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
lol, a new hire asked why there's no tampons or pads in the womens' rooms on the company message board and the first 10 responses were male developers going "why don't you consider part of your salary a stipend for bringing your own". lol. mansplaining is real y'all.

gonadic io
Feb 16, 2011

>>=

Bloody posted:

wait whats a list<a -> b>? is that a collection of functions?

yeah, sorry for my bastard hybrid of haskell and c#

I find that generics are easier to explain here using <> as not everybody knows haskell

But then the type signature of functions using Fn<a, b> is garbo so I fall back to haskells there

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

LeftistMuslimObama posted:

lol, a new hire asked why there's no tampons or pads in the womens' rooms on the company message board and the first 10 responses were male developers going "why don't you consider part of your salary a stipend for bringing your own". lol. mansplaining is real y'all.

hosed up

jony neuemonic
Nov 13, 2009

LeftistMuslimObama posted:

lol, a new hire asked why there's no tampons or pads in the womens' rooms on the company message board and the first 10 responses were male developers going "why don't you consider part of your salary a stipend for bringing your own". lol. mansplaining is real y'all.

terrible programmers indeed.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

gonadic io posted:

functor has map: List<a> -> (a -> b) -> List<b>
applicative also has ap: List<a> -> List<a -> b> -> List<b> (and pure: a -> List<a>)
monad also has bind: List<a> -> (a -> List<b>) -> List<b>

(substitute List with Option or whatever your favourite data structure is)

you can turn bind into ap and map (hence anything that's a monad is also an applicative functor and a regular one)

but you can't do it the other way around

i dont understand this notation at all, which is probably why i get lost whenever folks start explaining all this funcy monad stuff.

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
if you do C#, it's basically
code:
class List<A> {
    // List<A> as a Functor
    public List<B> Map(Func<A, B> f) {...}

    // List<A> as an Applicative
    public List<B> Ap(List<Func<A, B>> fs) {...}
    public static List<A> Pure(A a) {...}

    // List<A> as a Monad
    public List<B> Bind(Func<A, List<B>> f);
}
(this is just an approximation)

hobbesmaster
Jan 28, 2008

a->b is a fancy way of writing b somefunction(a)

yay lambda calculus

CPColin
Sep 9, 2003

Big ol' smile.

LeftistMuslimObama posted:

lol, a new hire asked why there's no tampons or pads in the womens' rooms on the company message board and the first 10 responses were male developers going "why don't you consider part of your salary a stipend for bringing your own". lol. mansplaining is real y'all.

In that case, the women in the office should be being paid 101% of what the men are. For the stipend.

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!

hobbesmaster posted:

a->b is a fancy way of writing b somefunction(a)

yay lambda calculus

it's really less fancy, and is the way all functions should be written

hobbesmaster
Jan 28, 2008

i don't see how that'd be functional

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
i've been on paternity leave for the past month and have forgotten how to write code

CPColin
Sep 9, 2003

Big ol' smile.
Java code:
public abstract class Baby implements Mom, Dad
{
   abstract void cry();
   abstract void drool();
   abstract void poop();

   public Baby(Mom mom, Dad dad)
   {
      // The fun part.
   }

   public void everyFifteenMinutes()
   {
      synchronized (mom)
      {
         synchronized (dad)
         {
            mom.notify();
            dad.notify();
         }
   }
}
This is a dumb joke.

GameCube
Nov 21, 2006

how does a baby implement the interfaces of a mom and a dad.

jesus WEP
Oct 17, 2004


VERY CAREFULLY

Luigi Thirty
Apr 30, 2006

Emergency confection port.

GameCube posted:

how does a baby implement the interfaces of a mom and a dad.

please don't erase intersex individuals

hobbesmaster
Jan 28, 2008

CPColin posted:

Java code:
public abstract class Baby implements Mom, Dad
{
   abstract void cry();
   abstract void drool();
   abstract void poop();

   public Baby(Mom mom, Dad dad)
   {
      // The fun part.
   }

   public void everyFifteenMinutes()
   {
      synchronized (mom)
      {
         synchronized (dad)
         {
            mom.notify();
            dad.notify();
         }
   }
}
This is a dumb joke.

because it makes no sense

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr

douglas crockford: "here's a comment :flipoff:"

quiggy
Aug 7, 2010

[in Russian] Oof.


The Something Awful Forums > Discussion > Serious Hardware / Software Crap > YOSPOS > Terrible programmers: you have come to a world called baby implements dad *whipcrack*

Shaggar
Apr 26, 2006

CPColin posted:

Java code:
public abstract class Baby implements Mom, Dad
{
   abstract void cry();
   abstract void drool();
   abstract void poop();

   public Baby(Mom mom, Dad dad)
   {
      // The fun part.
   }

   public void everyFifteenMinutes()
   {
      synchronized (mom)
      {
         synchronized (dad)
         {
            mom.notify();
            dad.notify();
         }
   }
}
This is a dumb joke.

yeah it doesn't make any sense

hobbesmaster
Jan 28, 2008

come to think of it its actually a good troll to see if anyone will try and fix the joke

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

CPColin posted:

In that case, the women in the office should be being paid 101% of what the men are. For the stipend.

in the name of cross-gender solidarity, i want a monthly stipend for buying MANPADs



bet i'd feel a lot more comfortable during salary negotiations

CPColin
Sep 9, 2003

Big ol' smile.

GameCube posted:

how does a baby implement the interfaces of a mom and a dad.

Well it's got to inherit from both of them somehow and Java doesn't let you extend more than one class.

Shaggar
Apr 26, 2006
you should use a factory pattern w/ the mom as AbstractBabyFactory and dad as input.

JimboMaloi
Oct 10, 2007

MrMoo posted:

The Java advanced set include some great examples of how not to code, annotations is hosed up, and lambda expressions is clear the author has no idea what lambdas are for.

holy poo poo is the annotations one bad. im thankful i generally only encounter code that uses a judicious subset of the spring annotations.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

working on basic texture mapping now

I've got my cube UV mapped and aligned to the squares on a checkerboard texture

hmm

Mao Zedong Thot
Oct 16, 2008


uncurable mlady posted:

IIS is loving garbage.

fritz
Jul 26, 2003

gonadic io posted:

yeah, sorry for my bastard hybrid of haskell and c#

I find that generics are easier to explain here using <> as not everybody knows haskell

But then the type signature of functions using Fn<a, b> is garbo so I fall back to haskells there

i dont think i get it

code:
ap: List<a> -> List<a -> b> -> List<b>
so you have:
1. an input List<a>
2. a List of functions that map an a into a b
3. an output List<b>

how do the sizes match up? like if the input List<a> has N elements, and there are M elements in the middle list, are there N*M elements in List<b> ? or does M have to equal N?

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

MrMoo posted:

No, not really. Basic stuff like CORS is just not obvious at all, and IIS is completely opaque in being able to quickly see how it is configured to do anything.

Yeah, apache was super easy. I just opened up httpd.config and just mashed on my keyboard until CORS was enabled it was very easy and obvious.

gonadic io
Feb 16, 2011

>>=

fritz posted:

i dont think i get it

code:

ap: List<a> -> List<a -> b> -> List<b>

so you have:
1. an input List<a>
2. a List of functions that map an a into a b
3. an output List<b>

how do the sizes match up? like if the input List<a> has N elements, and there are M elements in the middle list, are there N*M elements in List<b> ? or does M have to equal N?

these are the two ways that a list can be an applicative functor

1) n*m elements
2) min(n, m) elements

they're both equally valid applicative functors.

the former is a little more useful in practice since you can do non-deterministic calculations with it

Sapozhnik
Jan 2, 2005

Nap Ghost
oh i thought the ... -> ... -> ... notation was some dumb haskell currying thing

gonadic io
Feb 16, 2011

>>=

Mr Dog posted:

oh i thought the ... -> ... -> ... notation was some dumb haskell currying thing

it is


A -> B -> C
is
Fn<(A, B), C>

i.e. the type of
public C butt(A aThing, B bThing) {...}

it's quite interesting how f# tries to unify curried functions and uncurried functions

VikingofRock
Aug 24, 2008




fritz posted:

are there N*M elements in List<b> ?

It's this one. You apply all the functions in the function list to all the elements in the other list. So for example, let's say you have the list [1, 2, 3] and the list of functions [stringify_english(), stringify_spanish(), stringify_french()]. Then when you do the applicative functor thing using these two lists you would get ["one", "uno", "un", "two", "dos", "deux", "three", "tres", "trois"].

I actually always think lists are sort of weird examples of applicative functors / monads. The multiplying results are kind of confusing, and is it ["one", "uno", "un", "two"...] or ["one", "two", "three", "uno"...]? So maybe another example will help:

Let's say you have a nullable A , and a nullable function which takes an A and returns a B. Then you could make a new function which says "if the A or the function is null, then return null, otherwise return the function applied to the A". That function we just defined takes a Nullable<A> and a Nullable<(function from A to B)> and returns a Nullable<B>. This is pretty similar to how our first function took a List<A> and a List<(functions from A to b)> and returned a List<B>. The ability to define that sort of thing is most of what makes something an applicative functor. The remaining thing is that you need a way to put something into the applicative functor (so for example if I have a Char 'a' I can pretty easily turn that into a List<Char> (namely ['a']), or into a Nullable<Char> containing 'a').

Also there are some laws which these functions need to obey, which basically say that these function act in the intuitive way with the identity function and with each other. That's probably more detail than you need, but those laws are what answer my question earlier about the ordering of the resulting list. They also are what make it so that the "put something into a list" function applied to 'a' has to return ['a'], and not ['a', 'a'] or an empty List<Char>.

edit: lol I got the order wrong my first time writing this post.

VikingofRock fucked around with this message at 22:50 on Jul 29, 2016

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

gonadic io posted:

it is


A -> B -> C
is
Fn<(A, B), C>

i.e. the type of
public C butt(A aThing, B bThing) {...}

it's quite interesting how f# tries to unify curried functions and uncurried functions

uhh i'm probably misunderstanding you but it doesn't at all? or if it does it's a really crappy attempt

uncurried in c# : Func<a, b, c>,
or in f#: (a * b) -> c (which actually would be Func<Tuple<a, b>, c>)

curried in c#: Func<a, Func<b, c>>
or in f# : a -> b -> c

the two don't convert automatically or anything, you need to wrap them (speaking of which, here's a really cool script that automatically generates f#-y wrappers for .net libraries)

fun fact: according to MS guys, one of the main reasons it will still take months to support f# on .net native (windows 10 store) is that the .net native compiler shits the bed when asked to comple a Func<a0, Func<a1, Func<a2, Func<a3, Func<a4, Func<a5, Func<a6, Func<a7, Func<a8, Func<a9, Func<a10, b>>>>>>>>>>>

gonadic io
Feb 16, 2011

>>=

NihilCredo posted:

uhh i'm probably misunderstanding you but it doesn't at all? or if it does it's a really crappy attempt

uncurried in c# : Func<a, b, c>,
or in f#: (a * b) -> c (which actually would be Func<Tuple<a, b>, c>)

curried in c#: Func<a, Func<b, c>>
or in f# : a -> b -> c

oh. what lang am i thinking of then? poo poo

gonadic io
Feb 16, 2011

>>=

VikingofRock posted:

It's this one.

that's the one that haskell has chosen to make the default, but there's another way to make a list an applicative:

http://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Applicative.html#v:ZipList

calling pure :: a -> ZipList a
makes the ziplist an infinite list of As

VikingofRock
Aug 24, 2008




gonadic io posted:

that's the one that haskell has chosen to make the default, but there's another way to make a list an applicative:

http://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Applicative.html#v:ZipList

calling pure :: a -> ZipList a
makes the ziplist an infinite list of As

Oh yeah, I remember reading about this at one point. I don't think I've ever used it though.

Hey, you'll probably know this: is there any reason why [f, g] <*> [a, b] has to be [f a, g a, f b, g b] and not [f a, f b, g a, g b]? I thought I remembered that the latter broke an applicative law, and that's what I wrote above, but now that I think about it I can't figure out which law it breaks.

fritz
Jul 26, 2003

thanks vikingofrock and gonadic io !

VikingofRock posted:

Let's say you have a nullable A , and a nullable function which takes an A and returns a B. Then you could make a new function which says "if the A or the function is null, then return null, otherwise return the function applied to the A". That function we just defined takes a Nullable<A> and a Nullable<(function from A to B)> and returns a Nullable<B>. This is pretty similar to how our first function took a List<A> and a List<(functions from A to b)> and returned a List<B>. The ability to define that sort of thing is most of what makes something an applicative functor. The remaining thing is that you need a way to put something into the applicative functor (so for example if I have a Char 'a' I can pretty easily turn that into a List<Char> (namely ['a']), or into a Nullable<Char> containing 'a').

so a map wouldn't be able to deal with the "maybe a is null / maybe the function is null"

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
why would posting a multipart form with a pkcs12 key work in the browser, work in postman, not work in a go http request? the content type headers for the form parts are set appropriately. aren't we just sending bytes around?

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006
go is bad

  • Locked thread