Elm is Totally Total?

But I would not be able to write my own iteration functions?

Elm with Turing completeness is totally totally awesome. If it was totally toal, it would be totally totally useless, to me anyway.

1 Like

@norpan you can do >90% of normal cases with fold and map, but there are cases where they are not sufficiently expressive.

One example is traversing recursive data structures.

Another would be quitting early from traversing a very long list.

2 Likes

Brian, of course you lose some things when you do this. For instance having unbounded recursive data structures.

The question is, do you need them, or could we make a language that would work well for our applications anyway. Frontend applications are a bit of a special case of application.

2 Likes

I have unbounded recursive data structures that I consume from a REST API and display in the UI. They describe a content model, and it is possible to nest content inside other content.

I am also using unbounded recursive data structures to describe searches over state spaces - just experimenting with this at the moment, but I plan to use it to write a search for a graph layout algorithm.

Unbounded recursive data structures are kind of a big deal in functional programming.

1 Like

Yes, you’d want to handle unbounded, but not infinite data structures. So the question is, can you define such structures so that go get traversal that is guaranteed to terminate? This is an interesting topic, but I don’t think many people are suggesting this should be done in Elm.

1 Like

You might not want to disallow infinite recursion either, the Never type and never function are implemented using infinite recursion:

type Never = JustOneMore Never

never : Never -> a
never (JustOneMore nvr) =
    never nvr

Might be cool to have a totality checker, though.

1 Like