
Try Idris - jcurbo
http://www.tryidris.org/console
======
jcurbo
For those curious what Idris is, from [http://www.idris-
lang.org/](http://www.idris-lang.org/) : "Idris is a general purpose pure
functional programming language with dependent types. Dependent types allow
types to be predicated on values, meaning that some aspects of a program’s
behaviour can be specified precisely in the type."

Here's a couple of talks about Idris:

Edwin Brady at London Haskell:
[https://www.youtube.com/watch?v=vkIlW797JN8](https://www.youtube.com/watch?v=vkIlW797JN8)

David Christiansen at Haskell DC: [http://bmsherman.github.io/idris-
drc-3-26-14/](http://bmsherman.github.io/idris-drc-3-26-14/)

And there's a tutorial and other docs available here: [http://www.idris-
lang.org/documentation/](http://www.idris-lang.org/documentation/)

~~~
14113
Just to note, Edwin was the original author of Idris, so I'd definitely
recommend watching his talk.

Edit:

Given that my comment seems fairly high at the moment, I'll post a link to his
PhD thesis, which seems to be the genesis of Idris for anyone interested:
[http://eb.host.cs.st-andrews.ac.uk/writings/thesis.pdf](http://eb.host.cs.st-
andrews.ac.uk/writings/thesis.pdf)

------
pufuwozu
Hey everyone, I'm the creator!

Sorry for the problems - I was hotlinking to the awesome
[http://rawgit.com/](http://rawgit.com/) website during development and forgot
to remove it before posting it on Twitter.

The website should be fixed in just a few seconds. Thanks for trying it out!

------
skybrian
I'm glad to see dependent types move a bit closer to practical programming. I
read (well, skimmed) the tutorial and learned a little of what it's all about.
Being able to pass around assertions as first-class objects seems pretty
interesting.

However, I'm still confused about what's happening at compile time versus
runtime. Apparently some functions can be used in proofs (and are therefore
evaluated at compile time), while some proofs must be evaluated at runtime?

The notation isn't very helpful here. Since types are no longer strictly
compile time and values are no longer strictly runtime, it seems like we need
some other way to easily distinguish compile time and runtime.

~~~
ihm
See this page ([https://github.com/idris-lang/Idris-dev/wiki/Erasure-by-
usag...](https://github.com/idris-lang/Idris-dev/wiki/Erasure-by-usage-
analysis)) for info on erasure. Unused proof values or indices in data types
used for static checking are erased at compile time via usage analysis (if you
don't use it in the RHS of a function definition, it gets erased).

If you want to ensure that the indices of your data type or arguments to your
function are erased, you can use the new dot notation. E.g., if you give a
function called "half" the following type

    
    
      half : (n : Nat) -> .(pf : Even n) -> Nat
    

then the compiler will complain if the proof argument is actually used.

------
peter_l_downs
Here's what I saw:
[http://i.imgur.com/4yNB6t4.png](http://i.imgur.com/4yNB6t4.png)

    
    
        > This page abuses rawgit.com. You should complain to its
        > owner.

~~~
erikano
They can use cdn.rawgit.com instead, which is ok to use in production
according to [http://rawgit.com/#cdn](http://rawgit.com/#cdn)

------
Udo
_> You can use the REPL above to play_

I don't see anything like that on my screen (OS X, Firefox latest). It's
basically just three lines of code without any interaction.

~~~
fhars
The beginning of the HTML (including the head with the script links) is
[sometimes] missing from the page sent by the server.

------
sabalaba
I discovered Idris when I was playing around with Agda last summer. It's cool
to see a systems programming language with dependent types.

~~~
Dewie
> It's cool to see a systems programming language with dependent types.

What do you mean by 'systems programming language'?

~~~
Rusky
The tutorial says "The goal of the IDRIS project is to build a dependently
typed language suitable for verifiable systems programming. To this end, IDRIS
is a compiled language which aims to generate efficient executable code. It
also has a lightweight foreign function interface which allows easy
interaction with external C libraries."

I generally think of systems programming as drivers, kernels, embedded stuff,
and performance-sensitive applications like game engines. Not sure how far in
this direction IDRIS is going though. It feels a lot like the same niche as
OCaml, with dependent types.

~~~
edwinb
I tend not to use the phrase "systems programming" any more. "General purpose"
is probably better (or my current favourite "Pac-man complete"). I should
probably edit the tutorial to that effect. We've done simple network protocols
and packet formats (I had a student working on DNS for example) but not driver
or kernel level things.

That said, some people are experimenting with lower level things (thinking
about making a minimal run time system with no garbage collection for
example). It's not a primary goal, but it'll be interesting to see what comes
of it.

~~~
bjz_
> I should probably edit the tutorial to that effect.

Yes please do. Idris is a lovely language for bringing dependent types closer
to the realm of production code, but giving people false hopes is a little
cruel :)

~~~
tel
Take a look at ATS then! My understanding from playing around with it is it is
trying to be C with dependent types.

~~~
thinkpad20
ATS looks fascinating in concept, but what code examples I've seen, the syntax
is terrible and it's ridiculously verbose. I'm sure you could write absolutely
bulletproof code in it, but the productivity hit would render it almost
unusable for large-scale projects. I might be off here, of course... but one
of the lovely things about Haskell is that despite its reputation as a
difficult language, once certain key concepts are tackled, it's relatively
easy to program rapidly and create real world products (with a considerably
higher assurance of correctness than most languages provide). ATS seems
complex to a level that nearly guarantees its usage won't extend much beyond
academia.

~~~
doublec
If you use the non-dependently typed parts of ATS it is no more verbose than
most ML variants. If you use it without the GC then verbosity increased
because you need to add calls to free memory. If you add proofs or dependent
types then declaring those adds more. I've used it in moderately sized
production programs and it's similar to using OCaml or other ML in terms of
productivity. Once you're familiar with the language of course.

If I paraphrase what you said about Haskell it's true for ATS too:

    
    
        "but one of the lovely things about ATS is that despite its reputation as a difficult language, once certain key concepts are tackled, it's relatively easy to program rapidly and create real world products (with a considerably higher assurance of correctness than most languages provide)."
    

The key, like any language, is learning the concepts. I think people assume
ATS is more difficult than it is is because much of the documentation and
examples for it use a verbose style and heavy proofs. A post I wrote a while
back attempts to gently introduce ATS dependent types and you can see that the
non-dependently typed examples are very similar to any other ML language:

[http://bluishcoder.co.nz/2010/09/01/dependent-types-in-
ats.h...](http://bluishcoder.co.nz/2010/09/01/dependent-types-in-ats.html)

~~~
bjz_
> If you use it without the GC then verbosity increased because you need to
> add calls to free memory

The issue is that is the default mode I would like to work in. Rust is
designed to make that the natural mode of working, rather than the exception.
Fast, deterministic operations should be easier and more succinct than the
managed alternatives – in the context of a systems language that is.

> people assume ATS is more difficult than it is is because much of the
> documentation and examples for it use a verbose style and heavy proofs.

Then they need better docs. And a better website! And better marketing!

~~~
doublec
It's interesting looking at the different design decisions of languages. One
persons pro is another's con.

ATS2 has no GC as the default mode of working too. The only reason it is more
verbose is because you need the call to free. ATS strives to be explicit in
what it does so it's easier to read the code and know what is happening.

Languages with destructors or implicit function calls seem to lean towards the
C++ downside of "What does this code really do" when looking at it. I dislike
hidden code where there is no easily identifiable call to tell you something
is happening.

It's not all roses and unicorns with ATS either of course. What I really want
is the next generation of dependently typed system languages which has learnt
from the current ones.

~~~
bjz_
> you need the call to free

So how does ATS enforce memory safety? With Rust you have a bunch of library
types that you can reuse that abstract away from the memory management for
you. The types make sure you don't screw up. Unfortunately you can't prove
things about the `unsafe` blocks, and have to rely on careful auditing, but
that only needs to be done once, and then you have a nice, reusable
abstraction. Bookkeeping sucks.

> What I really want is the next generation of dependently typed system
> languages which has learnt from the current ones.

Agreed. At the moment Rust suits me the best, but I definitely don't think it
is the end of the road.

~~~
doublec
> So how does ATS enforce memory safety?

Linear types. Much like unique pointers in Rust, the type system tells you
when you fail to consume a linear type. A 'free' call would do this. Same with
closing files, etc - you use linear types to track that the resource is
consumed.

~~~
bjz_
Ah neat. Does it have regions?

------
orf
Functional languages interest me, but are not very approachable. I mean I
looked at the examples[1] page for Idris and came away completely confused,
why he hell does this sequence of characters "data Nat = Z | S Nat" define a
natural number? Or "data Maybe a = Nothing | Just a" somehow defines an option
type.

It would be good to have an introduction for people not too familiar with
functional languages.

1\. [http://www.idris-lang.org/example/](http://www.idris-lang.org/example/)

~~~
captainmuon
Right, I'm a big fan of functional programming, but I never got warm with
functional languages. One big reason is the syntax. I'd love to be able to
specify (in pseudo C(++):

    
    
        typedef positive_int: int {
            ensure {this > 0}
        }
        typedef ambulance: vehicle {
            ensure {this.has_siren && this.has_bed && this.color == "red"}
        }
    

and so on.

(aside: The other main problem I have with functional languages is the
following, I'm not sure what to call it but it bites me every time: You
finally find out how to do what you want in an elegant functional way, you
code it up and you're happy. Then, you want to make a small modification, but
it turns out that it's impossible with the current code, and you have to
rewrite everything with much less abstraction. I can't remember a great
example from the top of my head, but a simple one is, you'd like to add a
progress bar to a computation. It's trivial in imperative languages, but much
harder in functional style.)

~~~
discreteevent
Prof. Van Roy gives a good example of this in the Edx course "Paradigms of
Computer Programming" He uses the simple example of trying to introduce code
to a pure functional program that will record the number of times a particular
function is called. To do this you need to modify the signature of every
function on the call stack. No doubt there's some other way to do this and it
probably involves a monad but he was dealing with a simple pure functional
language in the example. His point was that in this sense the pure system is
not modular.

~~~
sold
That's exactly the point of monads - see
[http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/ba...](http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf).
Such a system is still pure, btw.

------
riffraff
> Failed to load resource: the server responded with a status of 503 (Service
> Temporarily Unavailable) [http://rawgit.com/chrisdone/jquery-
> console/master/jquery.con...](http://rawgit.com/chrisdone/jquery-
> console/master/jquery.console.js)

this causes the console not to load. It would be better to host the js
yourself, probably.

------
tel
Sadly the console seems to be missing and the compiler doesn't emit errors.

The second is more sad since so much of the dynamics of programming Idris
comes from the trying to get its statics to compile. In particular, you will
spend an inordinate amount of time staring down collections of type holes
trying to solve the puzzle they present.

None of that gets reflected in the compiled Javascript.

------
fprotthetarball
"This website abuses rawgit.com. You should complain to its owner."

~~~
double051
Yeah, saw this alert after switching between 'Console' and 'Compile'.

------
tempodox
This is one REPL, and compiler, that does not work and doesn't react to user
interaction. That doesn't exactly inspire confidence.

