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
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

no syntax highlighting? i'm not writing a go blog friend.

ok you can embed gists which is good enough but ugh this wysiwyg editor is really painful

DONT THREAD ON ME fucked around with this message at 22:26 on Jul 23, 2018

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
gently caress it rolling my own blogging engine

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

redleader posted:

i spent about zero seconds thinking through this analogy, so i'm sure someone is going to swing by and categorically explain why composability IS NOT lego and hurt my feelings

actually it's k'nex

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

eschaton posted:

write it in server side Swift!


Bloody posted:

write it in fullstack rust

honestly i'm not gonna do it because like jony neuemonic, i've already done it 3 times and i dont want to get distracted by something i already know how to do. but i really want to. maybe i will write a blog engine in both languages and then write a blog comparing and contrasting.

eschaton posted:

they’re both good just for different things

“class inheritance bad” is essentially denying the existence of is-a relationships, which is laughable on its face
*dies*

i'm being facetious. clearly a language needs to be able to model is-a relationships. i suppose i'd amend my statement to say "composition is better than complex inheritance.

eschaton posted:

fist eggplant medium can be a way to build an audience

putting your poo poo on your own domain (though hosted) is something you’ll want to do though

be sure to leverage Twitter etc. too, for audience engagement

micro.blog is easy to host stuff on, also can work like Twitter itself but also lets you host bigger content including photos and podcasts and can also act as a gateway/aggregator for your own hosted stuff (imagine if medium pulled from your wordpress server)

yeah i'm definitely going to market this around. the rust team just introduced some blog amplifying program where you submit your blog and they post it up all over the place so i'm gonna try and do that too.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
sublime text what is this, barely 3 years ago??

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Bloody posted:

i just want to write rust and get paid for it

let's do a startup

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
a rusty venture, if you will

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

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.

i'd live in milwaukee imo

i've never typed milwaukee before what a weird word

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
a wallet chain made from a block chain for holding your paper wallet

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

jit bull transpile posted:

Its an app meant for families and yeah I was thinking like 10 and 25 buck a month tiers based in what features they want.

follow your heart friend. you're smart and if it's actually a good idea i think you'll know

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
buy out several city blocks and turn it into an adult theme park fantasy land that is exactly like a normal city in every way except that trump was never elected president.

that's where i want to go on vacation.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
a space exploration startup whose only goal is to send elon musk to the kuiper belt

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
sorry, i'm done.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i had a streak of over-engineering 5 things and now i'm really cautious about it.

my natural inclination is to over-engineer, i really enjoy the process of greenfield poo poo so i go overboard and it's probably my worst quality as an engineer. fortunately i'm aware of it and do my best to combat it now.

i go hog wild in personal projects, though.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

rust magnetometer ststus: done and it calculates the angle from (magnetic) North it seems consistent but I have ordered a magnetic compass to check. This is much easier because I live on the Greenwich line so don't have to really correct for geographic vs magnetic north lol

It also calculates the angles between two (hard coded) GPS coords now too but I have to be careful not to check my address into my public github repo. Next up: loving around with stepper motors

how are you feeling about arduino as your choice for doing embedded stuff in rust? i'm super interested in learning more about embedded but i dont want to get super serious (yet).

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

For reference with my mkrzero (samd21g18a) I now need no unsafe code and no pointer loving which is a million times better than it was a year ago: https://github.com/djmcgill/coffee-compass/blob/master/src/main.rs

I have all three of gpio, uart, and i2c being used in this crate, no big deal. Nowhere near stable though, all version 0.1 of libraries and I'm even using a dude's branch of a library because his pull request hasn't been accepted yet

nice yeah, i want to do this. that is such a departure from the code i've been writing. i think i have byte anxiety.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
well then we really need to invent a font for people with dyslexia that isn't comic sans. the idea that there's a group of people out there who can only look at comic sans is heart wrenching.

DONT THREAD ON ME fucked around with this message at 14:05 on Jul 26, 2018

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
ya i think so. but maybe there’s a better way idk

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

TheCog posted:

At the risk of sounding ignorant, what is a p-lang?

also you’re not ignorant it’s yospos slang

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
rats (get it, cats in rust) update: we got kleisli
code:
    #[test]
    fn test_compose_and_map() {
        let parse = kleisli::apply(|s: &str| s.parse::<i32>().map_err(|_| "parse error").lift());

        let reciprocal = kleisli::apply(|i: i32| {
            if i != 0 {
                Ok(1.0 / i as f32)
            } else {
                Err("divide by 0")
            }.lift()
        });

        let parse_and_recriprocal = reciprocal.compose(parse);

        assert_eq!(parse_and_recriprocal.run("123").unlift(), Ok(0.008130081));

        assert_eq!(
            parse_and_recriprocal.run("yospos").unlift(),
            Err("parse error")
        );

        let doubled = parse_and_recriprocal.map(|f| f * 2 as f32);
        assert_eq!(doubled.run("123").unlift(), Ok(0.016260162));
        assert_eq!(doubled.run("0").unlift(), Err("divide by 0"));
    }
if you're interested in a better explanation of kleisli than i can provide, check it: https://typelevel.org/cats/datatypes/kleisli.html


this was tricky to implement. (sorry, i know this is useless without explanation, i'm working on it).
code:
pub struct Compose<A, K1, K2> {
    k1: K1,
    k2: K2,
    marker: PhantomData<*const A>,
}

impl<'a, F, A, B, C, K1, K2, Z, G> KleisliT<'a, F, C, B, Z, G> for Compose<A, K1, K2>
where
    A: 'a,
    B: 'a,
    F: Monad<'a, F, Z, G> + 'static,
    K1: KleisliT<'a, F, A, B, Z, G>,
    K2: KleisliT<'a, F, C, A, Z, G>,
{
    fn run(&self, a: C) -> Lifted<'a, F, B, Z, G> {
        F::flat_map(self.k2.run(a), |a| self.k1.run(a))
    }
}
`Z` and `G` are unfortunate: Since we want to support HKTs of more than one type parameter, we have to pass them around everywhere when they're not being operated on. however, aside from the explosion of type parameters, it works totally fine, but I've chosen to stop at 3 parameters (or 2 parameters and another HKT for rank N types!).

side note, I wish rust would let me do this:
code:
pub struct Foo<'a,A,B,C> where A+B+C: 'a
If I want to constrain a bunch of type parameters to the same trait or lifetime bound, i should be able to do so as above. I'm going to do a little research and maybe write an RFC. unless that syntax is reserved for some other use, i cant imagine objections as it reduces a lot of syntactic noise, which is a big problem for rust.

also: i still really don't get lifetimes, and this is tied up in my complete lack of understanding around how memory works. really looking forward to digging into c/c++ because rust isn't really helping with my intuition here.

also also: translating a well-documented library from one language to another is a really useful exercise for learning.

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

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
there's nothing good about it. it's a monstrosity. i feel nothing but shame.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
for real though, i'm just reading the cats source code and re-implementing it as well as i can in rust. i love it but it's definitely not good.

thanks though

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i just happen to like rats a lot.

also i had a sweet tooth tonight, so check out this sweet sweet syntactic sugar:

code:
/// Lifts a funtion Fn(A) -> L into a Kleisli where L implement Lift
pub fn lift<'a, F, A, B, Z, G, L>(run: impl Fn(A) -> L + 'a) -> impl Kleisli<'a, F, A, B, Z, G>
where
    L: Lift<'a, F, B, Z, G> + 'a,
    F: 'static,
    G: 'static,
    B: 'a,
    Z: 'a,
{
    self::run(move |a| run(a).lift())
}

/// Evaluate the Kleisli with A, and unlift the resulting Lifted
fn runlift(&self, a: A) -> <Lifted<'a, F, B, Z, G> as Unlift<F>>::Out
    where
    Lifted<'a, F, B, Z, G>: Unlift<F>,
    {
        Kleisli::<_, _, _, _, _>::run(self, a).unlift()
    }

    // and now the earlier example works without having to explicitly lift and unlift everything:  
    // (ok it's still explicit but a lot nicer)
    #[test]
    fn test_compose_and_map() {
        let parse = kleisli::lift(|s: &str| s.parse::<i32>().map_err(|_| "parse error"));

        let reciprocal = kleisli::lift(|i: i32| {
            if i != 0 {
                Ok(1.0 / i as f32)
            } else {
                Err("divide by 0")
            }
        });

        let parse_and_recriprocal = reciprocal.compose(parse);

        assert_eq!(parse_and_recriprocal.runlift("123"), Ok(0.008130081));

        assert_eq!(parse_and_recriprocal.runlift("yospos"), Err("parse error"));

        let doubled = parse_and_recriprocal.map(|f| f * 2 as f32);
        assert_eq!(doubled.runlift("123"), Ok(0.016260162));
        assert_eq!(doubled.runlift("0"), Err("divide by 0"));
    }

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

tinaun posted:

male shoegaze i think the inferred outlives rfc and the implied bounds rfc would help you out here and cover most of what you want. (it won't hurt to submit your rfc though, it doesn't seem like that large of an addition). there's also an ancient rfc about lifetime elision in impl headers that was accepted pre 1.0 and only now getting around to being implemented.

once these are implemented you wouldn't need to copy your lifetime requirements on every function and impl block that acts on the same types and it would reduce a lot of noise.

oooh yeah these would help a lot. as you said though, my suggestion seems harmless so i might give it a shot just for fun.

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.




eschaton posted:

does rust let you declare your own operators, using Unicode too?

because if not, there’s a project for shoegaze

get all APL up in here
oh man as someone who has experienced scala first hand: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. the only good custom scala operator i've encountered is `===`, which is good because the builtin equals is very bad. as much as i'm enjoying FP concepts i really don't like operator soup.

otoh, adding custom operators would be in keeping with my previous terrible programming language contribution: adding nested ternary expressions to Crystal.

Peeny Cheez posted:

Male Shoegaze has drunk deeply of the FP Kool-Aide

i know you're just poking fun but let me just state that I am not an FP zealot. It's really fun and it's making my brain grow and I'll definitely continue to apply a lot of these concepts to other things, but I don't think it's the best/only way to program. I just came off a year at a scala shop and I didn't get to explore these concepts as much as I wanted so here I am.

Powerful Two-Hander posted:

what the gently caress sort of moon language is this

it's good

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

:(

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

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

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

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
also tinaun plz explain pinning tyvm

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

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

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

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:

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.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

tinaun posted:

ok. but first lets talk about mem::replace

wow thanks! im taking a break from computer today but ill be working through this tomorrow!

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

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

it's so weird how memes work

i first saw this one you know like, 6mo-1yr ago in this thread.

and i didn't get it. so i looked it up and i thought "ok, whatever"

then i saw a few more and they didnt do anything for me

but now this one is funny.

memes are weird.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Woo, got kleisli compose and monad working with futures. It required wrapping the stored closure in the kleisli in an Rc, but the more I think about that the more it makes sense.

code:
    #[test]
    fn test_kleisli_map_and_compose() {
        let parse = kleisli::run(|s: &str| {
            // I think it's possible to get around the type annotations here but I need to redesign
            // a few things.
            let l: Lifted<FutureKind, i32, Nothing, Nothing> =
                future::lazy(move |_| s.parse::<i32>().unwrap()).lift();
            l
        });

        let reciprocal = kleisli::lift(|i: i32| future::lazy(move |_| 1.0 / i as f32));

        let parse_and_recriprocal = reciprocal.compose(parse);

        assert_eq!(
            block_on(parse_and_recriprocal.runlift("123")),
            0.008130081f32
        );
        let doubled = parse_and_recriprocal.map(|f| f * 2f32);
        assert_eq!(block_on(doubled.runlift("123")), 0.016260162f32);
    }
I think I'm going to do EitherT now, then I'll be able to do redo this example without unwrapping the results.

also i've been switching between RLS and Intellij a lot and RLS feels like it's catching up. It's a lot better at dealing with macros than intellij which is super important because a lot of the std lib stuff is macro based. For instance, intellij just doesn't understand futures v3, because a lot of the definitions are inside macro blocks. However, intellij can implement traits which is a majorly killer future for what I'm doing.

DONT THREAD ON ME fucked around with this message at 16:47 on Jul 29, 2018

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
true story i had no idea how to pronounce kleisli until i saw rob norris do a talk where he said it. i was saying something closer to khaleesi in my head.

also if you're interested in FP stuff I'd definitely recommend rob norris' talks / blogs, he's responsible for any of the understanding i have. i dunno that he's a guru but he's really likable and accessible.

https://tpolecat.github.io/presos.html

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

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

tinaun posted:

ok. but first lets talk about mem::replace

thanks again for this. reread it a few times. i'll need to experiment before it really clicks but it's not a mysterious and scary as it was at first.

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
the biggest thing i miss about red hat is the big on prem private cloud we had in lower environments for testing/validating pocs/etc. so nice, even if the UI was garbage.

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