It is, but if the process and tooling isn't really polished and responsive it feels really bad.
When everything is smooth though, it might be ideal. Jury still out on that one.
1,459 karma · joined October 19, 2011
http://codygman.github.io
It is, but if the process and tooling isn't really polished and responsive it feels really bad.
When everything is smooth though, it might be ideal. Jury still out on that one.
I'm expressing the wish that were I better at organizing them better that I could have tangled all of those snippets into a working (if ugly) source file and work from there.
Does that make sense?
> hello, quick question: i feel like there's a more elegant way to express this, but I'm struggling to come up with one:
foo :: (a -> Bool) -> (a -> Bool) -> a -> Bool
foo f g x = f x && g x
For those who aren't as familiar with Haskell, that is taking a function f and a function g, passing argument x to both, and then doing a binary and on their boolean result.One answer suggested:
> You can get fancy, but the “simple” version is almost always more readable:
(not . null . f $ x) && (not . null . g $ x)
Which I find myself agreeing with in many ways, but for some reason leaves me desiring more.The answer to that desire complements this article I think:
> if f and g returned Maybe you could have:
> f _ = Nothing
> g _ = Just ()
> x = ()
> (f x) <*> (g x)
Nothing
> import Data.Maybe
> (f x) <*> (g x) & isJust
False
> -- or to avoid <*> you can do
> liftA f g x
Nothing
If that's not clear, let me know what's confusing and I'll try to explain furtherIf it's just a few lines can you give an example?
I never got good at tangling my blocks together in the end though which is what I think would have made this method really powerful.
With just a modicum of effort you can easily disprove this feeling.
Yeah? I'm not sure how meaningful this argument is here since you can just get by with nano and a terminal.
> Which is how the "cult" (tongue-in-cheek) treats it, and why this person has FOMO.
I frequent the places that the "cultists" would most likely be and the prevailing theme is "if your workflow works, keep it, but emacs could do X for you".
> There are tons of examples of programming wizards and productivity gurus who don't use emacs.
Yeah, but that doesn't mean Emacs wouldn't make them less or more productive.
I don't think I've seen the "you need emacs" strawman your arguing against in practice.
> And you'll encounter lots of people who can't get shit done but who fiddle endlessly with emacs or vi or whatever configs and believe they have some super efficient direct connection from their brain to their computer.
Would those people be more or less productive without emacs? I find answering questions like this for myself difficult, I can't imagine trying to decide others would be better off not using an editor.
Isn't saying lots of people exist that would be more productive without the kind of presumption that annoyed you from the Emacs cult?
> Some of the best, most productive programmers I know use notepad, and some of the worst use emacs. ymmv.
Right, which is why I commented what the other user was missing and not "you need this".
Emacs has had structural editing for lisp how long?
Plus, it's nice to fallback to ctags or ripgrep if your lsp server dies
Text still is mostly everything for all of my backend programming, note taking, etc.
> The other problem is speed of typing is irrelevant if you are working with libraries all the time, which is basically what most of the programming world does.
Typing speed is far from the most important part. It's the consistent interface for everything, reduction of cognitive load, and everything being available at your fingertips in emacs.
You are missing an entire world treated as text and a consistent and an endlessly configurable interface for everything you can pull into your emacs Borg.
See this comment too: https://news.ycombinator.com/item?id=23673299
Note, many still use emacs for what the GP described and more.
Then when you sync your Emacs config to your laptop, those sharp edges remain gone.
Examples like this, especially those widely meaningful to everyone, are nearly impossible to craft.
It's like seeing different paths of movement before trying parkour and after training a few weeks.
What last link posted consisted mostly of fakes? I must have missed it.
Maybe my memory is fuzzy... But if not can you give an example where that wasn't the case?
Not if your logic is primarily in terms of domain types, invariants encoded in those domain types as is necessary and economical.
> And at that point, all the power you get from saying things like there's only one possible implementation of a function f :: a -> a immediately go out of the window, because you don't have a value of type a, you have a value of type SomeConcreteTypeThatIKnowThingsAbout.
Can you give an example? I can only see this being the case if your logic is done at the concrete type level.
Yes, kind of.
> When you're playing with cute mathematical code and almost everything is written in terms of totally generic types, it's cute that you get free theorems and automatic derivations of some basic functions and all that stuff.
It's not only "cute" as you so reductively put it. There are real world benefits.
> However, in the real world, 99% of the time we work with concrete types to get concrete work done, and there are going to be many possible implementations of a function of type Int -> Int, or MyDataStructure -> MyDataStructure -> MyDataStructure, or SomeWrapper SomeType -> (SomeType -> SomeOtherType) -> (SomeType -> SomeOtherType) -> SomeWrapper SomeOtherType. This remains true notwithstanding the possibility that some of that cute generic code was used to implement various small parts of the function you actually care about if you dig down far enough.
That presumes an arguably wrong method of developing software that needlessly eschews understanding and correctness confused for superior economic choices, finally resulting in "real world programming".
https://www.simplehaskell.org/
Then if you use simple Haskell for a year and want more type safety, you can fearlessly refactor to get that.
I understand the feeling, that's why it's very necessary to either find a very good teaching resource.
I'm currently reading "A Type of Programming" for fun and it kind of reminds me of "Why's poignant guide to Ruby in presentation (sadly sans artful illustrations)":
https://atypeofprogramming.com/ (do yourself a favor and at least click to read the well-written intro ;) )
The caveat (because there usually is one) being that it's 720 pages long. That's another tradeoff though.. you either get something that gets you all the way from point A to point B and it's very long or you get something very dense that requires lots of hammock time to derive the intuition yourself.
> I often wonder if Haskell is useful for anything
Also, I'll note that I write Haskell for my day job to combat your though of "wonder if Haskell is useful for anything".
> someone must be using it.
Yep :)
Given the example:
{
"baz": ...,
"bar": ...,
"foo": ...,
"quux": ...,
}
Then listing all of the keys in your desired order: comp :: Text -> Text -> Ordering
comp = keyOrder ["foo","bar","baz","qux"] `mappend` comparing length
Note if you list all keys in the first argument of keyOrder it never goes to comparing length. There is probably a cleaner way to denote that this is the case but I can't be bothered to figure it out atm.You can use this function:
encodePretty' defConfig { confCompare = comp } YourType
And it will produce: {
"foo": ...,
"bar": ...,
"baz": ...,
"quux": ...,
}
Can you give a sample of the javascript in the order necessary? This is from NPM? They have to use some comparison function to figure out how to sort their keys I'd imagine, so you could just copy that with Haskell.Kind of... correctness isn't as guaranteed though. Having a hard time putting it into words at the moment, maybe I just need some holes poked into it to draw out the rest of my view (or change it).
My day job disagrees Haskell isn't good for profit ;)
If you're sold on benefits of purely functional programming, I think it's good to know (at least as of a few years ago) Scala makes that more painful than Haskell if you have even a little Haskell experience.
This gets you most of the way there:
> With the Aeson library, the order of keys in objects is undefined due to objects being implemented as HashMaps. To allow user-specified key orders in the pretty-printed JSON, encodePretty' can be configured with a comparison function.
- https://hackage.haskell.org/package/aeson-pretty-0.8.7/docs/...
I'm not sure that messes with spacing or not though or you require specific space preserving requirements to interoperate with current clients.
Even if not you can probably look at the source of encodePretty' and work out how to not mess with spacing or keep it all on one line.
I've wanted a version of Aeson for a while that preserves order and all formatting for things like linters that are very unobtrusive. It seems your use case would have benefitted from that as well.
How do you know the harsh critics of Go you read barely used Go at all? What things did harsh critics try to build with Go that it wasn't aimed for, and/or what is the most frequent wrong thing those critics try to build with Go?
>> This is obviously false. How do you square that with all the Rust code we've shipped in Firefox, for example? I build things in Rust every day. - pcwalton
> I didn't state that no one builds anything in Rust so I have no need to square it. - Touche
Touche!
You are technically correct I suppose. You didn't state no one builds anything, but arousing suspicion that "a lot" of prominent Rust people aren't building anything and are just "snacking" on the language is pretty pointed rhetoric with an obvious purpose.
You could start up a Programming Language tabloid with a headline like:
EXPOSED: PROMINENT RUST PROGRAMMERS CAN'T EVEN WRITE IN RUST!
And really that's all before analyzing the line of logic of "people tweeting only about interesting language features and not their personal projects, public work projects, or private work projects implies they might just not be building anything at all" which seems pretty flimsy at best.
I think it's hard to discern between "that overly-complex functional and declarative definition is unfamiliar to me" and "that is way over-complicated and should just use a for loop".
Any chance you can track down that example so others can compare the two examples as well?
How so?
You know there has been a growing number of professional Haskell developers for the past 5-7 years right?