Live data from Hacker News

The Little Typer

mitpress.mit.edu

101–110 of 138 posts

Re: The Little Typer

#101
post #33

Is there a reason dependent types are not more common?

They can make libraries a pain. Like imagine if someone write a library in C#2025 with dependent types where functions took parameters like [i: i%2 == 0] or whatever. And your big project has no existing dependent types. There's no way to adopt this library unless you pull dependent types all the way in. Or even if you did, but your types were [i: i%4 == 0] or [i: (i+1)%2 == 1] or whatever, you'd have to write proofs…

If the project had no existing dependent types at all, couldn't you just perform a runtime check before calling the library? The check would return evidence that [i: i%2 == 0] for the particular i, or fail at runtime. If it succeeded, then you could invoke the library using the new evidence.

One appealing aspect of dependent types is that they let you decouple validation of inputs from the function calls themselves, while still disallowing passing wrong inputs to the function by mistake.

Re: The Little Typer

#102

Earlier quoted context omitted.

I'd hazard that a very large fraction of people who work on open PLs and open operating systems get paid --and expect to get paid -- for the effort they put into that project; take Golang, Rust, Linux, Kotlin, Java/JVM, Scala, Haskell, OCaml, Swift and so on. These are not written by homeless people. Try telling Rob Pike that he's not going to get paid for the ten years he spent on Go, and that he would only get paid…

If I understand your position correctly, you feel that even if someone does not have $40 or would not have paid $40 for something that can be freely copied, it is both immoral and unethical to ignore the author's wishes and copy it anyway. Even though you as the author are unaffected by this action. You also feel that it's justifiable to seek out people who do this and tell them that they should not do this, i.e. how…

How is this victimless?

I write a book, put it out on the market. Someone copies it and puts it up on a website (crime alert). Someone like you publicises it. I don't get paid because from your point of view, it is out there free for the taking. Meanwhile, I have lost hundreds or thousands of potential sales from people who may have paid, but have now been tempted to join your illegal caper. Everyone revels in the very public theft.

Which is why I seek out comments like yours that glorify piracy and tell them to bugger out of _my_ life. They are most welcome to their lives as long as they don't adversely affect mine.

Re: The Little Typer

#103

The book is fantastic. If you think this model is interesting, please consider trying Idris and reading the Idris book: https://www.manning.com/books/type-driven-development-with-i...

I learned a bit of Idris on the book you link, but I gave up after trying to implement Quicksort (the classical Haskell one-liner) in Idris vectors. You need to manually write a page of theorems for Idris to accept it. It's crazy.

Re: The Little Typer

#104

I can't tell if my question is off-topic or not, but.. Can anyone recommend a book (or whatever) that introduces the aspects of type theory relevant to a would-be language designer?

I recommend these introductory lectures to Category Theory. I'm going through them right now.

I assume you know some math/set theory and some Haskell, otherwise you may want to work though some of the chapters in Real World Haskell first.

Oh and put the videos at 1.25× or 1.5× otherwise you will fall asleep.

https://www.youtube.com/user/DrBartosz

Re: The Little Typer

#105

Earlier quoted context omitted.

If I understand your position correctly, you feel that even if someone does not have $40 or would not have paid $40 for something that can be freely copied, it is both immoral and unethical to ignore the author's wishes and copy it anyway. Even though you as the author are unaffected by this action. You also feel that it's justifiable to seek out people who do this and tell them that they should not do this, i.e. how…

How is this victimless? I write a book, put it out on the market. Someone copies it and puts it up on a website (crime alert). Someone like you publicises it. I don't get paid because from your point of view, it is out there free for the taking. Meanwhile, I have lost hundreds or thousands of potential sales from people who may have paid, but have now been tempted to join your illegal caper. Everyone revels in the ve…

So many assumptions are embedded in your comment. Firstly, it's not proven that piracy affects sales. Quite the opposite: it usually raises popularity for an item, because – if it's good – people sing its praises, which leads to more sales.

You didn't respond to my actual comment. Again, it is victimless because no one would've bought the overpriced book except for those who have $40 to throw away on a lark.

If we focus on making a quality product at a reasonable price, sales follow. The fact that technology has reduced this price to near $0 is unfortunate but is merely a consequence of computers.

I get that technology is often upsetting, but why take it out on users? The way to win is to pay attention to trends and adapt, not wish the world were different.

Riddle me this: Why did people write books before there was an economic incentive for them to? The crux of our disagreement appears to be this: it wouldn't hurt the world for us to return to those times. And technology seems to make this inevitable.

I wish I could get paid to write programming languages all day, but many people wish they could be paid for many things that are not feasible. Are you so sure your book would have maid those thousands of dollars in an era before it was possible to widely distribute it? Who would buy it? And moreover, who would hear about it and how?

https://www.gnu.org/philosophy/right-to-read.en.html

Of course, Lissa did not necessarily intend to read his books. She might want the computer only to write her midterm. But Dan knew she came from a middle-class family and could hardly afford the tuition, let alone her reading fees. Reading his books might be the only way she could graduate.

It's always interesting to watch Stallman's writings become reality.

In fact, this is so prescient as to be worth quoting in full:

Programmers still needed debugging tools, of course, but debugger vendors in 2047 distributed numbered copies only, and only to officially licensed and bonded programmers. The debugger Dan used in software class was kept behind a special firewall so that it could be used only for class exercises.

It was also possible to bypass the copyright monitors by installing a modified system kernel. Dan would eventually find out about the free kernels, even entire free operating systems, that had existed around the turn of the century. But not only were they illegal, like debuggers—you could not install one if you had one, without knowing your computer's root password. And neither the FBI nor Microsoft Support would tell you that.

Substitute "Microsoft Support" for "Apple". We even have officially-licensed and bonded programmers now: The $100 developer ransom.

Lissa did not report Dan to the SPA. His decision to help her led to their marriage, and also led them to question what they had been taught about piracy as children. The couple began reading about the history of copyright, about the Soviet Union and its restrictions on copying, and even the original United States Constitution. They moved to Luna, where they found others who had likewise gravitated away from the long arm of the SPA. When the Tycho Uprising began in 2062, the universal right to read soon became one of its central aims.

You claim you are a victim. Yet you refuse to acknowledge that there are people who can't afford your work who would otherwise be enriched by it. Of the two victims, it's hard to say which is worse. Especially given that people will continue writing books even when there is no incentive to.

Re: The Little Typer

#106
post #33

Is there a reason dependent types are not more common?

They can make libraries a pain. Like imagine if someone write a library in C#2025 with dependent types where functions took parameters like [i: i%2 == 0] or whatever. And your big project has no existing dependent types. There's no way to adopt this library unless you pull dependent types all the way in. Or even if you did, but your types were [i: i%4 == 0] or [i: (i+1)%2 == 1] or whatever, you'd have to write proofs…

You could just assert that i%2 == 0 via some postulate - as long as the proof is irrelevant for the code that is. Doing so is similar to converting from any in a gradual type system: if the assertion is correct you get correct code with little work and if you're uncorrect you're no worse off than if you had no types at all.

There are difficulties with dependent types, but having to go all in can be avoided via a shift in culture.

Re: The Little Typer

#107

Is there a reason dependent types are not more common?

Try to write the classic Haskell Quicksort in Idris:

    qsort :: Ord a => [a] -> [a]
    qsort [] = []
    qsort (p:xs) = qsort (filter (= p) xs)
and let me know how it goes, if you will. That's when I gave up on Idris.

Re: The Little Typer

#108
post #53
post #17

This book is a real joy to read. I got to peek at a draft at OPLSS 2017 and have been waiting impatiently for it to come out. The detailed, carefully worked examples one after another that this style of book is famous for is adapted beautifully to dependent type theory. Check it out! The code implementing the language in the book is here: https://github.com/the-little-typer/pie

Does the book discuss the implementation of the language or just usage of the language?

I believe it's more just how to use a dependently typed language (my copy is still in the mail). Like the Little Schemer, it's written in the Socratic style. I think the idea is that you can do it all in your head if you want, with a piece of paper covering up the column with the answers.

If you are interested in the implementation, you can read more about it from one of the authors: http://davidchristiansen.dk/tutorials/nbe/

Re: The Little Typer

#109

I can't tell if my question is off-topic or not, but.. Can anyone recommend a book (or whatever) that introduces the aspects of type theory relevant to a would-be language designer?

I recommend these introductory lectures to Category Theory. I'm going through them right now. I assume you know some math/set theory and some Haskell, otherwise you may want to work though some of the chapters in Real World Haskell first. Oh and put the videos at 1.25× or 1.5× otherwise you will fall asleep. https://www.youtube.com/user/DrBartosz

Don't get me wrong - CT is a super handy thing to learn, and it pops up a ton when thinking about any software, including type checkers and compilers, but the OP was specifically asking about type theory and programming language implementation. Yes, you can express lots of category theory in terms of type theory (the dream is to implement all of it in terms of TT so that we can mechanise it), but it won't be the best use of your time if you want to build a type system.

Re: The Little Typer

#110
post #33

Earlier quoted context omitted.

They can make libraries a pain. Like imagine if someone write a library in C#2025 with dependent types where functions took parameters like [i: i%2 == 0] or whatever. And your big project has no existing dependent types. There's no way to adopt this library unless you pull dependent types all the way in. Or even if you did, but your types were [i: i%4 == 0] or [i: (i+1)%2 == 1] or whatever, you'd have to write proofs…

If the project had no existing dependent types at all, couldn't you just perform a runtime check before calling the library? The check would return evidence that [i: i%2 == 0] for the particular i, or fail at runtime. If it succeeded, then you could invoke the library using the new evidence. One appealing aspect of dependent types is that they let you decouple validation of inputs from the function calls themselves,…

Yup, lots of people are under the impression that you need to prove everything when it comes to DTs. That's not true - you can indeed push these checks to runtime, and just have the compiler make ensure you do it.
Post reply on HN