HNHacker News
TopNewBestAskShowJobs

danidiaz

628 karma · joined December 22, 2012

productivedetour.blogspot.com
submissionscomments
danidiaz··on Interstellar object ‘Oumuamua covered in 'thick crust of carbon-rich gunk'
Reminds me of Terry Bisson's "They're made out of meat" http://www.terrybisson.com/page6/page6.html
danidiaz··on What if consciousness is not what drives the human mind?
Reminds me somewhat of the Sankhya school of Indian philosophy, which was strongly dualist but (unlike Cartesian dualism) considered thought processes as part of material reality, and spirit as some sort of "consciousness capability" which worked mostly as an spectator.

https://historyofphilosophy.net/samkhya

danidiaz··on Haskell for Mac IDE
> you can't write a simple for loop or do i/o.

You can often use the "for" function for things analogous to effectful imperative loops. http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-T...

danidiaz··on Functional calisthenics
Here is an answer in the CS Theory Stack Exchange that explains how: https://cstheory.stackexchange.com/a/18399/13730 (I'm not endorsing it as a practical way of doing it, mind you.)

The idea is that the only explicit recursion is contained in generic combinators "fold_result" and "unfold_result" that are "boring" in the sense that they can be derived mechanically from the "resultF" data type and do not actually know about the binary search; they just do recursion.

In practice, folds and unfolds tend to be more useful for other things.

danidiaz··on Functor-Oriented Programming
I'm not 100% sure of what the author had in mind, but here's a possible (and possibly dumb) example.

Imagine you need a 2-parameter "Lasagna" datatype wich is a non-empty list of alternating "a" and "b" elements. It could be used to model something like a timeline, perhaps.

Instead of constructing it by hand, you could express it as a composition of other stuff:

    import Data.List.NonEmpty
    import Data.Bifunctor
    import Data.Bifunctor.Tannen

    type Lasagna = Tannen NonEmpty (,)

    example :: Lasagna Char Int
    example = Tannen $ ('a',3) :| [('b',4),('d',6)]
http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-L...

https://hackage.haskell.org/package/bifunctors-5.4.2/docs/Da...

That type has a whole bunch of useful instances without even having to auto-derive them.

And you could have functions that manipulated the pairs without caring what shape the "outer functor" has.

danidiaz··on Functor-Oriented Programming
I've seen mentioned the "streaming" package as an example of this: http://hackage.haskell.org/package/streaming

"streaming" provides a Stream type which is parameterized by a Functor. The main module in the package provides very general functions which work for any functor and often involve natural transformations and functor compositions and sums. http://hackage.haskell.org/package/streaming-0.1.4.5/docs/St...

The "Streaming.Prelude" instantiates the functor with a pair type and provides the more concrete API that one would expect from a streaming library. http://hackage.haskell.org/package/streaming-0.1.4.5/docs/St...

danidiaz··on Haskell People
A monoid is an interface with two operations: one that produces an element out of thin air, and one that combines two elements.

It also comes with a contract, like the contracts of "equals", "hashCode" or Comparable in Java. The contract says that the operation must be associative, and that the element you produce out of thin air must be neutral: when you combine it with another element it leaves the other element unchanged.

One benefit of having such general interfaces is that you can reuse code across a wide range of domains. For example: the Comparator interface in Java can be seen as a monoid, with the "thenComparing" function as the combination operation: https://docs.oracle.com/javase/8/docs/api/java/util/Comparat... You could build a list of comparators and concatenate it, map a function that produces a comparator over a list and concatenate it, and so on.

Another benefit is that you can be quite general when specifying requirements for your functions. In Haskell, the Writer monad only requires the type of the accumulator to be an instance of Monoid. So you can user regular lists, difference lists, or the integers under addition.

Also in Haskell some composite types automatically satisfy an interface if their components do, saving you work. For example, a tuple of monoids is automatically a monoid. Any function that returns a monoid is itself a monoid as well. (Functions that begin and end in the same type can be monoids in a different way: the neutral element is the identity function and the combination operation is composition.)

danidiaz··on Dhall: a programmable configuration language that is not Turing-complete
For what is worth, Dhall lets you check if an expression is already in normal form: http://hackage.haskell.org/package/dhall-1.6.0/docs/Dhall-Co... so one could use Dhall as a "data-only" language without bothering with evaluation.
danidiaz··on Consistent Selenium Testing in Python
> I've done this twice. It's the only way I've ever gotten any sanity out of Selenium.

What are the benefits of this approach vs. explicitly waiting for the things that should appear in the page?

danidiaz··on Consistent Selenium Testing in Python
I try to use explicit waits whenever possible. Luckily, the Java client library provides a rich set of combinators for declaring them.

You can also define your own; they are basically functions from a WebDriver object to some other thing (usually a Boolean).

http://seleniumhq.github.io/selenium/docs/api/java/org/openq...

danidiaz··on Brian Aldiss has died
I distinctly remember some of his stories, in particular "Heresies of the Huge God" https://archive.org/details/Galaxy_v24n06_1966-08 and "Confluence", which is structured as a glossary for an alien culture.

"Hothouse" is quite a fun read as well.

danidiaz··on Firefox 55 and Selenium IDE
I agree that is is important to structure the application to facilitate testing. But I find this surprising:

> And while recorders present some challenges, manually coding UI-level tests make the maintainability issue an order of magnitude worse.

In my experience, writing the tests manually for sufficiently "regular" applications ends up being more maitainable because you can put repeated logic in shared functions and classes, making it easier to adapt to changes in the GUI. Page Objects are an example of that: https://github.com/SeleniumHQ/selenium/wiki/PageObjects

Also, writing the tests manually lets you use "explicit waits". http://elementalselenium.com/tips/47-waiting Specifying exactly what we expect to happen tends to be more robust (and faster) than either using static sleeps or some kind of implicit wait. Recorders tend to have problems finding concrete things to wait for, especially for very dynamic pages.

(That said, I'm not against using something like Chrome DevTools to identify elements in the page, evaluate potential selectors, and so on. That is indeed useful.)

danidiaz··on Firefox 55 and Selenium IDE
Exactly, there is a degreee of flakiness beyond which you don't gain much assurance from your tests and you spend more time fighting fires in the testsuite than actually testing your app.
danidiaz··on Firefox 55 and Selenium IDE
Test recorders are an antipattern. They lure you with their "no programming required!" siren call, but the generated scripts invaribly end up as a fragile, poorly abstracted mess.

GUI tests suites, especially those created with recorders, are prone to become unmaintainable beasts full of flaky tests.

This old interview with Bret Pettichord makes good points about the use of recorders: https://youtu.be/s_CUPs6xAWw?t=590

danidiaz··on Javascript Arrays and Functional Programming
Sometimes this style is called "origami programming".
danidiaz··on Elm in Production: 25K Lines Later
One could use a generics library to emulate something like Go's struct field tags, which decouple "external" fields names from the actual field names. Something like this is explained from 48:50 in this talk: https://skillsmatter.com/skillscasts/10181-fun-with-sum-and-...

But perhaps it wouldn't save much code compared to custom-made parsers.

danidiaz··on Proust and Science Fiction
A very science-fictional (or anti-science-fictional) passage from Proust is:

> A pair of wings, a different respiratory system, which enabled us to travel through space, would in no way help us, for if we visited Mars or Venus while keeping the same senses, they would clothe everything we could see in the same aspect as the things of the Earth. The only true voyage, the only bath in the Fountain of Youth, would be not to visit strange lands but to possess other eyes, to see the universe through the eyes of another, of a hundred others, to see the hundred universes that each of them sees, that each of them is; and this we do, with great artists; with artists like these we do really fly from star to star.

R. A. Lafferty has a delightful short story with this very premise, appropriately titled "Through other eyes": https://archive.org/stream/Future_Science_Fiction_47_1960-02...

danidiaz··on The computer poetry of J. M. Coetzee’s early programming career
Michel Houellebecq worked as a programmer, too (and he didn't like it).

I suppose Kafka would work in programming, had he been born in our time.

danidiaz··on Medieval Scholars Believed in the Possibility of Parallel Universes
The counterintuitive moral of the story seems to be that ideological censorship has the potential to spur philosophical and scientific progress, even if this is an unintended and not very frequent outcome.

It is strange, but for a good chunk of time religious thinkers were "more right" about subjects like the eternity of the universe than the prevailing aristotelian philosophers, sometimes deploying surprisingly modern-sounding ideas in the process. I'm thinking of authors like Philoponus https://historyofphilosophy.net/philoponus and Crescas https://historyofphilosophy.net/crescas

The Stanford Encyclopedia of Philosophy has an entry on the condemnation of 1277: https://plato.stanford.edu/entries/condemnation/

danidiaz··on Things that Idris improves things over Haskell
A haskell version of 1) is talked about here: https://www.reddit.com/r/haskell/comments/55bvt4/typesafe_pr... It uses the "singletons" library (no relation to the singleton design pattern) that emulates some features of dependent types.
danidiaz··on Things that Idris improves things over Haskell
An interview with the creator of Idris in the Code Podcast: https://soundcloud.com/podcastcode/edwin-brady-on-dependent-...

Another cool feature of Idris is elaborator reflection https://www.youtube.com/watch?v=pqFgYCdiYz4 which I believe has no direct Haskell analogue (template Haskell perhaps?)

danidiaz··on Rust as a gateway drug to Haskell
There was a recent post about "imperative Haskell": http://vaibhavsagar.com/blog/2017/05/29/imperative-haskell/

The code in this other post about implementing string distance metrics is also quite imperative: https://markkarpov.com/post/migrating-text-metrics.html

danidiaz··on A computational linguistic farce in three acts
When he talks about the "computational models of language" that ruled in the 80s, is he referring perhaps to stuff like Montague semantics? https://plato.stanford.edu/entries/montague-semantics/ Or is Montague semantics merely a descriptive framework without practical applications?

What were the main "practical" approaches for natural language understanding back then?

danidiaz··on Personal Identity (2015)
Derek Parfit saw his reductionist view of personal identity as ultimately liberating, in an almost Buddhist sense:

> "Is the truth depressing? Some may find it so. But I find it liberating, and consoling. When I believed that my existence was a further fact, I seemed imprisoned in myself. My life seemed like a glass tunnel, through which I was moving faster every year, and at the end of which there was darkness. When I changed my view, the walls of my glass tunnel disappeared. I now live in the open air. There is still a difference between my life and the lives of other people. But the difference is less. I am less concerned about the rest of my own life, and more concerned about the lives of others."

But I wonder if such view can have more sinister interpretations. For example, a "parfitian" might become obsessed in imposing his own worldview and tastes on other people, feeling that this affords him a measure of "immortality". A bit like the ancient greek heroes' thirst for fame, perhaps. https://en.wikipedia.org/wiki/Kleos#cite_ref-4

> "When doubts invade us and cloud our faith in the immortality of the soul, a vigorous and painful impulse is given to the anxiety to perpetuate our name and fame, to grasp at least a shadow of immortality. And hence this tremendous struggle to singularize ourselves, to survive in some way in the memory of others and of posterity … Each one seeks to affirm himself, if only in appearance … Man habitually sacrifices his life to his purse, but he sacrifices his purse to his vanity. He boasts even of his weaknesses and his misfortunes, for want of anything better to boast of, and is like a child who, in order to attract attention, struts about with a bandaged finger." —Miguel de Unamuno, The Tragic Sense of Life

danidiaz··on Alexander Grothendieck: A Country Known Only by Name
The Grothendieck song: https://www.youtube.com/watch?v=GJ1S3tFaImo
danidiaz··on Databases from finite categories
The book "Big Data Integration Theory" also uses category theory to model database mappings: https://www.goodreads.com/book/show/19361242-big-data-integr...
danidiaz··on Medieval and Early Modern Coinage and Its Problems
A good book about medieval money is "Money and Its Use in Medieval Europe" by Peter Spufford: https://www.goodreads.com/book/show/1387158.Money_and_Its_Us...

Another interesting paper by Meir Kohn, this one about the evolution of the bill of exchange: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=151849

danidiaz··on The Soft Side of Software
Cont is one of the trickier monads to "get".

Cont r a is a computation that knows how to produce an "a" but, instead of returning it directly, passes it to a function that takes the "a" and produces an "r".

Compared to typical sequential execution, this gives more power to the "current" phase of the computation, because it might choose to invoke the passed a -> r function more than one time, none at all, inspect the resulting "r" and change course based on the result, etc.

danidiaz··on Merging Maps
Haskell's "containers" package has a whole module devoted to map merging: http://hackage.haskell.org/package/containers-0.5.10.2/docs/...
danidiaz··on What is so ‘scientific’ about Sanskrit?
Not about mathematics, but Heidegger subscribed to the dumb notion that philosophy could only be done in Greek and German: https://philosophy.stackexchange.com/questions/37972/what-is...
← PreviousPage 5 of 9Next →