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.
 
  • Post
  • Reply
FormatAmerica
Jun 3, 2005
Grimey Drawer
javascript also has the triple equals, for when you really want it equals

e: they do completely different things, === in js exists because js is bad

Adbot
ADBOT LOVES YOU

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
it's really cool that for some reason when otherwise reasonable programmers get into that FP Good poo poo they suddenly forget all about the concept of "reasonable function or variable names" or "comments" and nobody's expected to blnk an eye

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


FormatAmerica posted:

javascript also has the triple equals, for when you really want it equals

e: they do completely different things, === in js exists because js is bad

this is how terrible I am: when you open any script file in our solution vs will barf a load of warnings of "==, I think you mean ===" and I ignore them all

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Powerful Two-Hander posted:

this is how terrible I am: when you open any script file in our solution vs will barf a load of warnings of "==, I think you mean ===" and I ignore them all

:(

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 9 years!)

Powerful Two-Hander posted:

this is how terrible I am: when you open any script file in our solution vs will barf a load of warnings of "==, I think you mean ===" and I ignore them all

i've got this but with "use single quote not double quote" in typescript.

Chalks
Sep 30, 2009

Powerful Two-Hander posted:

this is how terrible I am: when you open any script file in our solution vs will barf a load of warnings of "==, I think you mean ===" and I ignore them all

carry on then posted:

i've got this but with "use single quote not double quote" in typescript.

tslint autoFixOnSave is the setting you've been waiting for.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Powerful Two-Hander posted:

this is how terrible I am: when you open any script file in our solution vs will barf a load of warnings of "==, I think you mean ===" and I ignore them all

yeah that's pretty terrible

don't use == unless you absolutely have a reason to compare and allow javascripts weird type conversion rules to do their thing

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Blinkz0rz posted:

yeah that's pretty terrible

don't use == unless you absolutely have a reason to compare and allow javascripts weird type conversion rules to do their thing

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness

otoh don't kill yourself fixing a bunch of terrible javascript that you didnt write

Captain Foo
May 11, 2004

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

MALE SHOEGAZE posted:

otoh don't kill yourself fixing a bunch of terrible javascript that you didnt write

faking your death and fixing JavaScript in Belize, tho

Luigi Thirty
Apr 30, 2006

Emergency confection port.

down there they use CocaScript

Captain Foo
May 11, 2004

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

Luigi Thirty posted:

down there they use CocaScript

the p in p lang stands for peru

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Phobeste posted:

it's really cool that for some reason when otherwise reasonable programmers get into that FP Good poo poo they suddenly forget all about the concept of "reasonable function or variable names" or "comments" and nobody's expected to blnk an eye

it's because functional programming is just an excuse to never have to come up with names for your variables

tinaun
Jun 9, 2011

                  tell me...

MALE SHOEGAZE posted:


completely unrelated question because i'm pretty sure i saw your name on the futures 0.3 pr: my "lifting" works fine with futures 0.1 and futures 0.2, but sadly doesn't work with the new stdlib futures in nightly because they aren't object safe as they're using arbitrary self types. Do you have any idea if there are plans to lift the restrictions on object safety to allow arbitrary self types or if some other workaround is planned? I really want to put these futures in a box. nm i just googled it and yes: they're working on it.


watch this space. until then you could use FutureObj to store boxed futures 0.3 Futures, as all Box<F> where F: Future03 can be freely converted to a FutureObj. its useful!


yesterday i got invited to be a maintainer of futures-rs, so thats cool i guess.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

tinaun posted:

watch this space. until then you could use FutureObj to store boxed futures 0.3 Futures, as all Box<F> where F: Future03 can be freely converted to a FutureObj. its useful!
nice! i'll give that a shot.

e: I gave it a shot, it almost works but I'm stuck because it looks like you can only convert into a FutureObj from a Box<Future<Output=()>> (as opposed to Output=A)? that doesn't really make sense to me, hmm.

quote:

yesterday i got invited to be a maintainer of futures-rs, so thats cool i guess.

that's awesome, i'd be extremely chuffed about that if i were you

DONT THREAD ON ME fucked around with this message at 17:13 on Jul 27, 2018

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


tinaun posted:

watch this space. until then you could use FutureObj to store boxed futures 0.3 Futures, as all Box<F> where F: Future03 can be freely converted to a FutureObj. its useful!


yesterday i got invited to be a maintainer of futures-rs, so thats cool i guess.

that's awesome

I can't wait until I can actually use them

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
also tinaun plz explain pinning tyvm

gonadic io
Feb 16, 2011

>>=

MALE SHOEGAZE posted:

nice! i'll give that a shot.

e: I gave it a shot, it almost works but I'm stuck because it looks like you can only convert into a FutureObj from a Box<Future<Output=()>> (as opposed to Output=A)? that doesn't really make sense to me, hmm

you got
code:
impl<F: ?Sized + Future> Future for PinBox<F>
and
code:
impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox<F> where
    F: Future<Output = T> + 'a,

impl<'a, T> FutureObj<'a, T> {
    pub fn new<F>(f: F) -> FutureObj<'a, T> where
        F: Send + UnsafeFutureObj<'a, T>,  
}
which look to me like they work. incidentally this is one of the things that the rust docs need more work on, because it's really not clear how all the different To and From and blanket impls interact. a favourite one is how the Display trait gives you the ToString trait which gives you the to_string method, but ToString isn't directly implemented by the types so the to_string method doesn't show up anywhere on their documentation

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Blinkz0rz posted:

yeah that's pretty terrible

don't use == unless you absolutely have a reason to compare and allow javascripts weird type conversion rules to do their thing

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness

born to script
type safety is a gently caress
eval em all 2018
i am js man
410, 757,864,530 ignored warnings

cinci zoo sniper
Mar 15, 2013




Powerful Two-Hander posted:

born to script
type safety is a gently caress
eval em all 2018
i am js man
410, 757,864,530 ignored warnings

mailorder bees
Nov 4, 2011

Powerful Two-Hander posted:

born to script
type safety is a gently caress
eval em all 2018
i am js man
410, 757,864,530 ignored warnings

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Oh I didn't notice this, let me try harder.

e: yeah that worked, thanks! unfortunately since the future needs to be send that means I have to constrain some of the typeclass methods to also be send, eg for functor, the Fn(A) -> B function would need to be send. This would be fine if I could limit that requirement to the future functor only, but I don't think I can.

e2: oh I think I can just use a LocalFutureObj instead.

DONT THREAD ON ME fucked around with this message at 18:57 on Jul 27, 2018

Bloody
Mar 3, 2013

i have found an excuse to spend my friday at work writing rust

qhat
Jul 6, 2015


If you don't like the default latex font just use lmodern sans, it's much better.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
hurray:

code:
    #[test]
    fn test_kleisli_future_map() {
        let k = kleisli::lift(|i: i32| {
            future::lazy(move |_| i)
        });
        let k = k.map(|i| i * 2);
        
        assert_eq!(block_on(k.runlift(15)), 30);
    }

    #[test]
    fn test_applicative() {
        let fut = future::lazy(|_| "yospos").lift();
        let fut2 = future::lazy(|_| "bictch").lift();

        assert_eq!(
            block_on(FutureKind::product(fut, fut2).unlift()),
            ("yospos", "bictch")
        )
    }
not particularly useful but neat. i can't get compose working due to lifetime issues with my kleisli implementation, but i think i have lifetime in the wrong spot.

DONT THREAD ON ME fucked around with this message at 21:02 on Jul 27, 2018

Soricidus
Oct 21, 2010
freedom-hating statist shill
replaced a horrendously fragile mess of regexes with an antlr grammar today

naturally the main outcome is that i am now aware that none of the inputs are actually well-formed

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Bloody posted:

i have found an excuse to spend my friday at work writing rust

tell us about your rust project

Bloody
Mar 3, 2013

it is a state machine that supports testing a system. it talks to a system over udp, and uses a couple threads to do so for reasons

im actually encountering a cumbersome pattern right now in my state machine logic. steps in the state machine are a function of the current state and the time in the state. the state is an enumeration, but the time is a float. as a result, my match looks like:

code:
match state {
    State::first => if time > 5f32 {
        Some(State::next)
    } else {
        None
   }
...
}
I'd like to just match (state, time) and then say like
(State::first, > 5f32) => Some(State::next)
(State::first, _) => None
but that doesn't work (obviously)
is there a pattern i could be using here that does work? I'd like to be able to clean it up to much fewer lines

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

Bloody posted:

it is a state machine that supports testing a system. it talks to a system over udp, and uses a couple threads to do so for reasons

im actually encountering a cumbersome pattern right now in my state machine logic. steps in the state machine are a function of the current state and the time in the state. the state is an enumeration, but the time is a float. as a result, my match looks like:

code:
match state {
    State::first => if time > 5f32 {
        Some(State::next)
    } else {
        None
   }
...
}
I'd like to just match (state, time) and then say like
(State::first, > 5f32) => Some(State::next)
(State::first, _) => None
but that doesn't work (obviously)
is there a pattern i could be using here that does work? I'd like to be able to clean it up to much fewer lines

code:
(State::first, time) if time > 5f32 => {}

This is called a match guard: https://doc.rust-lang.org/book/second-edition/ch18-03-pattern-syntax.html

gonadic io
Feb 16, 2011

>>=

Fergus Mac Roich posted:

code:
(State::first, time) if time > 5f32 => {}
This is called a match guard: https://doc.rust-lang.org/book/second-edition/ch18-03-pattern-syntax.html

you don't even need to include time in the match to have a condition on it in the guard:

code:
match state {
    State::first if time > 5f32 => {}
    State::first => {}
}

Bloody
Mar 3, 2013

a ha! i was at the top of that page just now. thanks!

i wonder if i could write a clippy lint to detect the dumb thing i was doing instead and recommend match guards...

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

gonadic io posted:

you don't even need to include time in the match to have a condition on it in the guard:

code:
match state {
    State::first if time > 5f32 => {}
    State::first => {}
}

rust is awesome.

gonadic io
Feb 16, 2011

>>=

Fergus Mac Roich posted:

rust is awesome.

standard haskell feature to the point where this became a way to avoid a huge chain of if-else blocks:
code:
 case () of
    _ | 5 > 3 -> undefined
    _ | "next case" == "butt" -> undefined
    _ -> undefined
vv: also that, please excuse my haskellcentricism

gonadic io fucked around with this message at 22:11 on Jul 27, 2018

MononcQc
May 29, 2007

I think most functional language that have pattern matches and guard sequences for them support that feature.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

MononcQc posted:

I think most functional language that have pattern matches and guard sequences for them support that feature.

yeah, but are those languages zero cost *and* fearlessly concurrent? :smug:

gonadic io
Feb 16, 2011

>>=
haskell is more "a cost between 2x and 2000x and you can't know ahead of time which it'll be" and trivial concurrency

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
before i'm done with my functional rust library thing i'm definitely going to try and benchmark it against at least scala. interested in memory performance as well as speed. i'm trying to implement trampolining now and am curious to see how that performs against scala in a fold right.

gonadic io
Feb 16, 2011

>>=
zero cost functor idea:

code:
macro_rules! map {
    ($x: expr, $f: expr) => $x.map($f)
}
:q:

raminasi
Jan 25, 2005

a last drink with no ice

Phobeste posted:

it's really cool that for some reason when otherwise reasonable programmers get into that FP Good poo poo they suddenly forget all about the concept of "reasonable function or variable names" or "comments" and nobody's expected to blnk an eye

i was trying to read the f# compiler source today because i was curious about something and idk if compiler code is always terrible or i’m really just that much dumber than don syme but oh lordy it was utterly incomprehensible

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

raminasi posted:

i was trying to read the f# compiler source today because i was curious about something and idk if compiler code is always terrible or i’m really just that much dumber than don syme but oh lordy it was utterly incomprehensible

Some of column a, some of column b

Adbot
ADBOT LOVES YOU

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

jit bull transpile posted:

I have an actual product idea but it would be subscription based and I'd want to HQ in Milwaukee instead of the stupid sf bay so it's doomed from the start probably.

make the HQ in MSP and i will work for you. and/or i will be an unpaid hype-man because i do not have actual job experience touching codes

i suggest this because wisconsin is still a bit :chloe: atm

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply