TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Types Can Be Like Tests

3 pointsby ahuthover 5 years ago

2 comments

TheAsprngHackerover 5 years ago
Agda and GHC Haskell have a feature called &quot;typed holes&quot; that can enhance the workflow that you describe in the article. If you&#x27;re not sure how to finish a definition, you can leave a &quot;hole&quot; in the expression where you are stuck, and the compiler will tell you what type you need to fulfill and list variables that might be helpful. Then, you can &quot;fill&quot; the typed hole with an expression, while possibly creating new holes. Thus, types can guide you as you incrementally build up an implementation.<p>Types let you to have a &quot;dialogue&quot; with the compiler. Programming in Agda is very much intended to be an interactive experience, via its Emacs mode.<p>Typed holes in GHC: <a href="https:&#x2F;&#x2F;wiki.haskell.org&#x2F;GHC&#x2F;Typed_holes" rel="nofollow">https:&#x2F;&#x2F;wiki.haskell.org&#x2F;GHC&#x2F;Typed_holes</a><p>Agda Emacs mode: <a href="https:&#x2F;&#x2F;agda.readthedocs.io&#x2F;en&#x2F;v2.6.0.1&#x2F;tools&#x2F;emacs-mode.html" rel="nofollow">https:&#x2F;&#x2F;agda.readthedocs.io&#x2F;en&#x2F;v2.6.0.1&#x2F;tools&#x2F;emacs-mode.htm...</a><p>In the article, you compare the usage of types to guide you with test-driven development. There is actually a book called Type-Driven Development about using dependent types in the Idris language, although I have not read it. It is written by Edwin Brady, the creator of Idris. <a href="https:&#x2F;&#x2F;www.manning.com&#x2F;books&#x2F;type-driven-development-with-idris" rel="nofollow">https:&#x2F;&#x2F;www.manning.com&#x2F;books&#x2F;type-driven-development-with-i...</a>
评论 #22149853 未加载
ahuthover 5 years ago
Author here. I do practice TDD, which is where I think this thought came from. Types aren&#x27;t exactly like tests, but we can use them for some of the same goals, such as constraining and influencing our implementations.<p>The example here may also be an example of development by &quot;wishful thinking&quot; (writing our implementations as if we had certain abstractions available), that is talked about in the SICP lectures.