Hacker News new | past | comments | ask | show | jobs | submit login

> I don't know why you had problem with compiling... All you have to do is run `agda --compile src/Main.agda` and it just works...

My point was that most Agda code I've written, or seen others write, is used to prove theorems; the result is rarely run. Even when implementing "real" algorithmic programs, it's usually just to prove that they satisfy some property, rather than actually using them to do anything ;)

> This is true to some extent, but this has nothing to do with Agda.

It's not inherent to Agda, but it's true in the sense that I could do "stringly typed programming" in Agda (i.e. using big, imprecise types which require a bunch of redundant checking and the compiler won't help me with), but there wouldn't be much point (I might as well do that in, say, Python and benefit from the vast amount of libraries and tooling).

> you can write a whole bunch of unittests that'll be checked at typecheck time.

I do this whenever I'm writing Agda or Idris, and it's so satisfying. The 'test framework' is just the type system, e.g.

    test_parse_empty : Eq (parse "[]") Nil
    test_parse_empty = refl
When I'm testing in most languages I tend to do property checking, e.g. QuickCheck/Hypothesis/etc. I haven't been brave enough to do that during type checking yet ;)



I even do

    _ : (f x y) == expected; _ = refl
makes tests shorter.

I also put my tests in the same file that define them by adding a private module

   module X

   record X : ...

   private
     module test where
        _ : (f x y) == expected; _ = refl
This way it's not possible to export record X without its tests passing.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: