0

For example when implementing a Show instance for the following type:

data Shape = Circle Double
           | Box Vector2D
           | Polygon (List Vector2D)
           | Chain (List Vector2D)

...and omitting the Chain case, Idris will successfully type check this file.

Similar issues go for implementing other functions.

Adding %default total at the beginning of the file doesn't seem to help this, but my impression was that it should.

corazza
  • 31,222
  • 37
  • 115
  • 186

2 Answers2

1

With this:

%default total

data DataType = A | B | C

Show DataType where
  show A = "A"

I get

$ idris Testme.idr
Type checking ./Testme.idr
Testme.idr:5:1-13:
  |
5 | Show DataType where
  | ~~~~~~~~~~~~~
Main.DataType implementation of Prelude.Show.Show is possibly not total due to: Prelude.Show.Main.DataType implementation of Prelude.Show.Show, method show

Please note that you will not see this kind of warnings in Atom - they do not seem part of the compiler / editor protocol.

Markus
  • 1,293
  • 9
  • 10
0

There is an option you can call idris with:

--total Require functions to be total by default

I'm still not sure if this is the only way, why %default total seems to do nothing, and whether it's possible to only get a warning when a function is not total.

corazza
  • 31,222
  • 37
  • 115
  • 186