HNHacker News
TopNewBestAskShowJobs

danidiaz

628 karma · joined December 22, 2012

productivedetour.blogspot.com
submissionscomments
danidiaz··on The Little Typer
> the ugly downsides of dependent types and how to avoid them

There's this Reddit answer from two years ago, and the subsequent comments https://www.reddit.com/r/haskell/comments/3zc81v/tradeoffs_o...

danidiaz··on Functional core, imperative shell (2012)
In the Idris language, one best practice is to relegate to the outer shell not only IO effects, but also "partiality"—in the sense of computations that might enter an unproductive infinite loop.

(In Haskell, one way of getting into unproductive infinite loops is by mistakenly asking "parse elements until the first failure" to a parser combinator that can always succeed without consuming input.)

The ideal is that the core of the application should be both pure and total, purity and totality being tracked by the type system. In fact, one can often relegate partiality to a single function of the outer shell.

danidiaz··on BuBBLE: A Lisp Dialect DSL Written in Haskell
There's also a Haskell writen in Lisp (in Racket, to be exact) https://www.youtube.com/watch?v=g6UCeHiKodo
danidiaz··on Never patterns, exhaustive matching, and uninhabited types in Rust
Types that represent producers of data often return a special result value at the end, of a type different from the values that are yielded. Say, a stream of integers that return a Boolean when it's exhausted.

By choosing an unhabited return type, you can express that the stream never stops producing values by itself.

danidiaz··on If monads are the solution, what is the problem?
> The essence of monad is thus separation of composition timeline from the composed computation's execution timeline

I also feel that it makes sense. Haskell prefers expressions to statements. When needed, statement-like things are constructed from expressions.

danidiaz··on Haskell’s State monad is not a monad (2014)
Some linear type systems garantee that functions defined in them have polynomial time complexity: http://www.cs.cmu.edu/~fp/courses/15816-s12/misc/hofmann03ic... http://www.kurims.kyoto-u.ac.jp/~terui/lalcjournal.pdf It appears however that the ones developed so far are awkward to "program" in.
danidiaz··on Vim plugins I use
Strictly speaking, one doesn't even need a plugin to use ack, ag or ripgrep from Vim. It is enough to set the "grepprg" option (perhaps also "grepformat") and then one can invoke the built-in ":grep" command.

For example, to use ripgrep:

    set grepprg=rg\ --vimgrep\ --no-heading
danidiaz··on Vim plugins I use
I use the default package functionality of Vim 8.x (see :h package).

I create a ".vim\pack\foo\start\" folder and git clone plugins there.

Invoking ":helptags .vim\pack\foo\start\somenewplugin\docs" for a plugin makes the docs available to the :h and :helpgrep commands.

danidiaz··on Quicksort in Idris
: is used for type annotations instead of :: like in Haskell.

The double asterisk is syntactic sugar for a "dependent pair" http://docs.idris-lang.org/en/latest/tutorial/typesfuns.html... Basically, it is a pair in which the type of the second element depends on the value of the first element.

Here it is being used to pack the result list with a proof that the list satisfies the required properties. The type of the proof must refer to the list, hence the need for dependent types.

The stuff within braces {} are implicit arguments http://docs.idris-lang.org/en/latest/tutorial/typesfuns.html... that are not given explicitly, but are inferred from the type of other arguments.

Type is commonly referred as the kind * in Haskell, the kind of types that have values.

Unlike in vanilla Haskell, the types of data constructors are explicitly stated http://docs.idris-lang.org/en/latest/tutorial/typesfuns.html... In Haskell the "types" of data constructors are kinds, and you need to enable the XKindSignatures extension to give them explicitly. https://downloads.haskell.org/~ghc/latest/docs/html/users_gu...

danidiaz··on The Ottoman Empire: Succession, Deposition and Fratricide
The Ottoman History Podcast is consistently interesting: https://soundcloud.com/ottoman-history-podcast/tracks
danidiaz··on If Haskell is so great, why hasn't it taken over the world? (2017)
In his talk about "milestones in the development of lazy, strongly typed, polymorphic, higher order, purely functional languages" David Turner mentions that the wan't adverse to SASL (https://youtu.be/QVwm9jlBTik?t=1819) and Miranda (https://youtu.be/QVwm9jlBTik?t=2330) —both predecessors of Haskell—to be used in industry. Getting out of the ivory tower was not a last minute idea, it seems.
danidiaz··on A little Duplex scepticism
Reminds me of "project Milo" from back in 2009 https://en.wikipedia.org/wiki/Project_Milo https://www.youtube.com/watch?v=CPIbGnBQcJY
danidiaz··on More fun with reactive-banana-automation
Ah I see. Events form a Monoid, so I guess I could have a "something happens" event aggregating all the sensor updates, and sample the "inverterPowerChange" Behaviour at the occurrences of the Event.

The API for reactive-banana doesn't seem to have a "value changed" combinator that creates an Event from a Behaviour alone; one must sample the Behaviour with another Event.

(Other FRP libraries somewhat similar in philosophy like reflex—not the JS Reflex—do seem to have Behaviour-like things that can fire events on change: http://hackage.haskell.org/package/reflex-0.4.0.1/docs/Refle... Although reactive-banana seems simpler to understand.)

danidiaz··on More fun with reactive-banana-automation
The reactive-banana code does more things; it also does the equivalent (in Observer pattern terms) of adding observers to the corresponding observables.
danidiaz··on More fun with reactive-banana-automation
I have a small quibble about the names though—or perhaps I didn't fully understand the example.

Since "inverterPowerChange" returns a Behaviour http://hackage.haskell.org/package/reactive-banana-1.2.0.0/d... which is supposed to be "inspectable" at any point in time, shouldn't PowerChange, PowerOff and PowerOn actually be PoweredState, PoweredOff and PoweredOn? The former sound more like event names. Or perhaps should "inverterPowerChange" return an Event instead? http://hackage.haskell.org/package/reactive-banana-1.2.0.0/d...

danidiaz··on Why Do Fantasy Novels Have So Much Food?
A science-fiction novel in which food is central to the plot is "Alastor: Wyst" by Jack Vance. The characters are bored by the tasteless food they usually have to eat ("Some gruff and deedle, with some wobbly to fill the cracks!") and go on expeditions ("bonterfests") in search for tasty, natural morsels.
danidiaz··on The Collector’s Fallacy
Old problem. The book "Too Much to Know" by Ann Blair is about how intellectuals dealt with information overload in early modern Europe: https://yalebooks.yale.edu/book/9780300165395/too-much-know
danidiaz··on Interstellar communication. IX. Message decontamination is impossible
Looks like the plot of "A for Andromeda" https://en.wikipedia.org/wiki/A_for_Andromeda
danidiaz··on APL Style: Patterns/Anti-patterns
How about "cacopattern"? https://en.wiktionary.org/wiki/Category:English_words_prefix...
danidiaz··on Clojure Don’ts: Lazy Effects (2015)
The streams/sinks work in the IO monad and that induces an ordering of the effects, yes. Within the callback, you can still do things like filtering or taking only a part of the stream.

Returning the stream itself from the "withFile" and trying to run it later still is still a bug.

I like this approach better that conventional Haskell lazy I/O, which I personally find quite confusing.

danidiaz··on Clojure Don’ts: Lazy Effects (2015)
One possible solution is to take a "beautiful fold" http://hackage.haskell.org/package/foldl-1.3.7/docs/Control-... and connect it to an effectful stream of bytes http://hackage.haskell.org/package/pipes-bytestring-2.1.6/do... inside the callback of "withFile".

Not unlike the Streams/Collectors framework in Java.

danidiaz··on Beautiful folds in Haskell (2016)
Collectors in Java >= 8 are quite reminiscent of these "beautiful folds", so much that I have wondered why the standard library lacks a proper Applicative-like composition method, which is so useful for avoiding multiple traversals of the data.

Something like it can be defined: https://stackoverflow.com/questions/30210547/grouping-by-obj... although the signature is a bit ugly.

danidiaz··on A look at the J language: the fine line between genius and insanity (2012)
The talk "APLicative Programming with Naperian Functors" shows an approach to APL-like programming in Haskell https://www.youtube.com/watch?v=D1sT0xNrHIQ

Many APL idioms, when translated to Haskell, are related to applicative functors. A smidget of dependent types is needed as well, to express the dimensions of vectors, arrays, and the like.

danidiaz··on Detecting Consciousness (2017) [pdf]
I was thinking in a naturalist way, it's just that the hypothesis seems naive to me. As I read it, it says more than simply "minds are products of brains": it says that certain characteristics of our subjective conscious experience must have "implementations" that mirror those characteristics quite directly.

I suppose computer analogies are cliché, but consider virtual memory: it gives the illusion of a huge contiguous memory space, when in reality the machine has nothing of the sort. Our brains are much more complex than computers and I suspect extrapolating between "abstraction levels" will be even more risky there.

I also don't see why "Integrated Information Theory" with its "formal calculus" is really required for the methodology of studying patterns of neural activity and trying to match them with self-reported states of consciousness.

danidiaz··on Detecting Consciousness (2017) [pdf]
But in the case of light, we are detecting a physical thing that is related by causal chains to the change in pigments.

The relationship between the subjective feeling of consciousness and the measured neural patterns doesn't seem to be of the same nature. When I see the color blue, does that "cause" anything in my brain?

danidiaz··on Detecting Consciousness (2017) [pdf]
I find the wording "detecting consciousness" problematic. They are not detecting consciousness as if they were detecting subatomic particles in a cloud chamber, or pollutants in the water; they are just measuring some neural fireworks that they believe coincide in time with the reported subjective experiences of the patients.

Then there's this:

> The current most promising scientific theory of consciousness [...] is Integrated Information Theory (IIT). [...] IIT emphasizes the differentiated and integrated aspect of any subjective experience and postulates that the mechanism supporting conscious experience in the human brain’s neocortex must likewise incorporate these two attributes.

I don't see any reason why the presumed features of our subjective experience should be "reflected" in the physical working of our brains.

danidiaz··on Hiring Developers: look for the ability to abstract and not for experience
Two more:

"The abstract is no more than an instrument, an organ, to see the concrete clearly." —José Ortega y Gasset

"Good general theory does not search for the maximum generality, but for the right generality."—Saunders Mac Lane, who knew a thing or two about abstraction

danidiaz··on An Italian Song That Sounds Like English But Is Nonsense
Reminds me of the "dream of the mayor" sequence in the classic Spanish film "Welcome Mr. Marshall", during which the aforementioned character imagines himself as the hero of a western: https://youtu.be/0reKaJTs4k8?t=30
danidiaz··on Homotopy Type Theory and Higher Inductive Types
Introductory talk: "A Functional Programmer's Guide to Homotopy Type Theory" https://www.youtube.com/watch?v=caSOTjr1z18
danidiaz··on A different view on Functional Programming
One could also say that functional programming prefers expressions to statements —and treats functions as just another expression. When needed, statement-like things are constructed from expressions.

Equations in lambda calculus do seem to have a "preferred direction" specified by the evaluation rules, though referential transparency lets you go "in the other direction" in your head, when reasoning about your program.

Perhaps the programs ~ equations idea would apply even better to logic programming, or term rewriting?

← PreviousPage 4 of 9Next →