Readit News logoReadit News
evincarofautumn commented on Haskell is a Bad Programming Language (2020)   blog.shitiomatic.tech/pos... · Posted by u/fpoling
malf · 5 years ago
> Functors are basically an Object with a internal state changing method in typical OOP terms.

This lets me safely ignore the rest of the article.

evincarofautumn · 5 years ago
Wow, I honestly wonder if this was caused by mixing up “functor” in the C++ and Haskell senses…

To expand on that, for those in the audience:

In Haskell, a functor is a type constructor (like “list”, “optional”, “future”, “I/O request”, &c.) with a way to map a function over it, covariantly, in a way that preserves its structure—i.e. without changing the shape of the container or structure of the action represented by the constructor, just the contained elements or produced result.

This is based on the more general notion of a functor in mathematics, which is a mapping between categories. The Haskell version is much more constrained, though: it only maps between Haskell types, and it’s parametric (iow completely generic), not just any old mapping.

While in C++, a functor is a completely different thing: an object that can be called like a function. It’s thus equivalent to a closure, where the object fields are the captured values. And that sounds like the description being used here.

evincarofautumn commented on Type-Level Programming in Rust   willcrichton.net/notes/ty... · Posted by u/fanf2
steveklabnik · 5 years ago
We have a project group working on "safe transmute", here's their first RFC https://github.com/rust-lang/rfcs/pull/2981

It cites the Haskell work: https://github.com/jswrenn/rfcs/blob/safer-transmute/text/00...

evincarofautumn · 5 years ago
Cool, thanks!

I’m thinking about a similar sort of coercion system for a language project, and it’s good to have a slightly broader view of the design space. This area hasn’t been very well explored yet, not just in terms of semantics, but also developer ergonomics: most of the time you want to hide representations for convenience, but when considering safe coercions, you really want to make it possible to talk about them explicitly & precisely.

This feature is also very subtle, and right at the very edge of the type system, so it’s extremely easy to break soundness here, usually by failing to consider things like variance. The reason “roles” were added to GHC in the first place isn’t just because of the issue with type families / associated types mentioned in that RFC; it’s also because anything that provides a safe API atop unsafe internals could also be used to violate soundness, especially in conjunction with mutation. The classic examples are: 1. coercing “container of A” to “container of B” using the coercion from A to B, then inserting a B that is not a valid A, either in its value or just because A and B have incompatible trait instances (like ordering or hashing). You need to be able to disallow conversions between things even if they have identical representations.

evincarofautumn commented on Type-Level Programming in Rust   willcrichton.net/notes/ty... · Posted by u/fanf2
chrismorgan · 5 years ago
Further to this: transmute is really pretty dangerous, and you’ve got to be very careful if you use it, or you’ll invoke undefined behaviour. And I believe the transmutes in the original article do invoke undefined behaviour, since the layout of the struct is undefined (you’d need to use something like `#[repr(C)]` on the struct to make it be defined). In practice, these particular examples are at least 99.9999% sure to do the right thing in all versions of Rust ever, but you just shouldn’t ever do this—you’re playing with delayed-action napalm. With his background, I feel that Will should have known better than to use unsafe here in this way: because it’s wrong.

Admittedly the SecureVec example is more understandable: because the generic is passed through to Item as well, you’ll need to convert the Vec<Item<T, ItemLevel>> to a Vec<Item<T, MaxLevel<ItemLevel, VecLevel>>>, which… well, it can be done readily enough without unsafe code, by consuming the Vec, mapping each item and collecting to a new vec, but short of a kind of specialisation magic that I don’t think will kick in in this case, that’s going to entail allocating a new vector, so that I would be inclined to use unsafe code here for efficiency; but care should still be taken that it doesn’t invoke undefined behaviour.

But one more word in defence of the transmutes: it makes it obvious that it’s either zero-cost or just a copy, whereas more involved things can become subject to compiler optimisations, so that you don’t know that the whole supposedly-noop transformation will be being optimised out of existence. That confidence and clearly-stated intent is valuable.

evincarofautumn · 5 years ago
Has there been any work in Rust on something like Haskell’s ‘Coercible’? Namely, it defines the precise criteria for safe zero-cost coercions between types that provably have the same representation, and derives the coercions automatically. It guarantees that ‘coerce’ is identical to ‘fmap coerce’, which saves the cost of that exact traverse+reconstruct pattern to change out a phantom type parameter.

There are some deficiencies, most prominently that the “role” system is aggressively monomorphic, so you can’t always prove that two things are coercible—the compiler must conservatively assume that type parameters with unknown roles cannot be coerced—but overall it’s much better than what we had before, and I expect it’ll continue to improve.

evincarofautumn commented on The C-- Language Specification (2005) [pdf]   cs.tufts.edu/~nr/c--/exte... · Posted by u/headalgorithm
evincarofautumn · 6 years ago
I would love to use it for my compiler backend…if I could find any maintained standalone implementations of it.
evincarofautumn commented on Pink Trombone   dood.al/pinktrombone/... · Posted by u/errozero
mobilejdral · 7 years ago
I have actually used this very tool back in the day to help learn how to speak in a male or female voice. One of the five things I do is manipulation of my tongue to change the cavity of my mouth to make the space bigger (more masculine) or smaller (more feminine) which this tool demonstrates very well.

Edit: to be clear I used to sound male 24/7 and now I sound female 24/7 Rather than thinking you are speaking male or female it helps if you think you are playing a musical instrument with a number of controls that you control (with your mind whahahaha). Then it is just about learning what each control does and how to play them so you get the result you want.

Your voice is muscle memory so while at the start I had to actively "play" a female voice that is no longer the case and now if I ever want to "play" a male voice I have to actively think about how I am going to speak each word to make it male.

evincarofautumn · 7 years ago
This is also exactly how male countertenor singers produce a female-sounding voice, by making the vocal cavity smaller to adjust the formants upward. If you don’t do that, it just sounds like a male head voice or falsetto.
evincarofautumn commented on Facts about smell (2014)   alicebartlett.co.uk/blog/... · Posted by u/Tomte
evincarofautumn · 7 years ago
I have an extremely strong sense of smell, inherited from my mother. Both of us are able to detect smells at lower concentrations and identify them more accurately than almost anyone else I know. My partner has told me that there are many things she didn’t even realise had a smell until I pointed it out—she is not anosmic, because she could recognise the smell after I drew her attention to it, as long as it has a high enough concentration. I have identified people I know by smell (who left their sweater behind at the party?), detected someone slicing cucumbers or celery a few rooms away, can identify what the neighbours are cooking, have pinpointed the location of certain types of ant nest, and more. If anyone is studying smell and wants to use me as a guinea pig, feel free to get in touch! I also have synaesthesia, which may play a role in how I process smells, but it seems to be mainly a physical thing.
evincarofautumn commented on The Why of Y (2001) [pdf]   dreamsongs.com/Files/WhyO... · Posted by u/pmoriarty
kannmig · 7 years ago
Another great exposition on the applicative-order Y combinator can be found at the end of Chapter 9 of The Little Schemer.

It is interesting to contrast with how in Haskell, one can simply define Y as

  Y f = f (Y f)
owing to the fact that it is lazily evaluated.

evincarofautumn · 7 years ago
Of course, the definition we actually use is this:

    -- (1)
    fix f = let x = f x in x
Because it has better memory usage; the definition you provided is translated to the following STG:

    -- (2)
    fix f = let x = fix f in f x
So whereas #1 is a thunk that refers to itself, #2 is a recursive function, and importantly not tail-recursive.

evincarofautumn commented on Differential coding of perception in the world’s languages   pnas.org/content/115/45/1... · Posted by u/Osiris30
evincarofautumn · 7 years ago
My working model for why colours admit description more readily than smells is that we judge and decompose them in largely the same way, but it’s simply easier to develop a repertoire of colours. They’re everywhere, most people have decent colour vision, and someone can point to them and tell you what they are in relative isolation.

Whereas smells (and tastes) are much more diverse, and rarely pure, isolated chemicals but more often complex profiles of many different compounds.

A common way that people develop a repertoire of smells is through cooking: now that I have some experience with many different ingredients and styles, I can now readily tell what went into a dish and how I might replicate it, describe new tastes in terms of old ones, and imagine new flavour combinations and how they would work together.

Chemistry offers another angle—if you know what I mean by “indolic” then you can probably conjure a mental image of exactly the heavy musk I’m referring to, but you probably have no clue if you haven’t experienced it and been told that that’s what you’re experiencing. You can add specific chemicals to your repertoire of smells.

A similar thing seems to hold for recreational drug experiences. If someone has had many different drugs before, especially drugs with similar pharmacodynamics that operate on the same receptors, it’s relatively easy to give them the gist of what something is going to feel like by reference to similar experiences. If they haven’t, there’s only so much you can do to prepare them for what is going to be a novel experience.

evincarofautumn commented on East German secret police guide for identifying youth subcultures (1985)   twitter.com/industrial_bo... · Posted by u/ilamont
creep · 7 years ago
It's many things at once. For some people, it's just an aesthetic. It's the whole "hacker, rebel, techy, lone-wolf" aesthetic.

It's also a genre of science fiction. It basically combines futuristic tech with dystopian/utopian elements, and grimy, old-world stuff. For example, a cyberpunk setting may have godlike AI, but everyone lives in the ghetto. Usually there are rogue actors that try to disrupt or exploit the technology system in place-- the "hackers". These actors are all about reclaiming old tech, building gadgets, and often cyborg-like body mods.

Cyberpunk is a sort of philosophy as well, along the same lines. This is where the subculture aspect comes in. Ever heard of steampunk? Steampunk in a fictional setting is where all technology is mostly mechanical, usually drawing on Victorian elements as well, and sometimes magic or supernatural stuff is included. Steampunk can be boiled down to an initiative to create stable, reliable, mechanically sound systems, usually put to interesting/novel use.

Cyberpunk as a subculture is similar. It's all about making tech work for you, pushing it to its limits, experimenting and exploiting within the given system. It's a rebellious attitude and a response to corporate and government tech control. It incorporates a fashion element like all good subcultures, likes to resurrect old tech (like nixie tubes), and often incorporates body modification (like NFC chips under the skin). People like to repair their own technology, modify their own technology, and collect obscure technologies. Many are also hackers, or want to be.

evincarofautumn · 7 years ago
> It basically combines futuristic tech with dystopian/utopian elements, and grimy, old-world stuff.

In other words, “The future is already here—it’s just not very evenly distributed” — William Gibson.

And it will probably always be that way, not just in terms of global inequality, but even in a single person’s life: you might be among the billion or two people living as humans have lived for thousands of years, on subsistence agriculture and herding with no running water, but you also have a smartphone and can video-chat with your cousins across the world. That aspect of cyberpunk storytelling is just taking this fact of existence and amplifying it to draw attention to it.

evincarofautumn commented on The 'Window of Opportunity' to Act on Climate Change Is 'Almost Closed' UN Warns   motherboard.vice.com/en_u... · Posted by u/joeyespo
evincarofautumn · 7 years ago
What can we do as individuals? I already eat relatively little in the way of animal products, don’t drive much, don’t use a lot of electricity or natural gas at home…but one person behaving this way isn’t enough. The only way I see us fixing this is through enormous collective action: holding to account the top 100 companies who together are responsible for 71% of GHG emissions, completely phasing out gasoline-burning vehicles, taxing the hell out of fossil fuels and emissions including methane from industrial farms, powering electric vehicles with renewable/nuclear power, decommissioning coal power plants, investing in dense walkable/bikeable cities and high-quality public transportation, and investing in carbon sequestration tech.

I’m scared and I feel so powerless because of the sheer scale of the problem, and how a lot of people don’t even believe in the problem. It’s paralysing me.

u/evincarofautumn

KarmaCake day4810March 18, 2011
About
A programming language technologist, or something like that.

https://github.com/evincarofautumn

http://evincarofautumn.blogspot.com/

evincarofautumn@gmail.com

View Original