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.

Formality, a (proof)gramming language featuring optimal reductions

27 pointsby LightMachineover 5 years ago

3 comments

jazzyjacksonover 5 years ago
I haven’t been able to grok this formal logic stuff, so I just want to give props to the animation at the bottom of your git readme. It looks very... mathy yet playful and makes me want to know what’s happening :)
0-_-0over 5 years ago
Surely the title should say "pro(of)gramming language", not "(proof)gramming language". What is a gramming language?
评论 #20940752 未加载
johnburnhamover 5 years ago
I&#x27;m one of the developers working on Formality and want to add a some links to:<p>- Our docs (docs.formality-lang.org)<p>- Our standard library (<a href="https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base</a>)<p>- Our Telegram channel (<a href="https:&#x2F;&#x2F;t.me&#x2F;formality_lang" rel="nofollow">https:&#x2F;&#x2F;t.me&#x2F;formality_lang</a>)<p>One thing I&#x27;ve been particularly enjoying with Formality is how we can implement structures like `Monoid`, `Profunctor`, `Monad`, etc. directly as types, rather than requiring type class machinery.<p>Haskell can do this too, of course (as described in Gabriel Gonzalez&#x27;s classic &quot;Scrap your type classes&quot; post <a href="http:&#x2F;&#x2F;www.haskellforall.com&#x2F;2012&#x2F;05&#x2F;scrap-your-type-classes.html" rel="nofollow">http:&#x2F;&#x2F;www.haskellforall.com&#x2F;2012&#x2F;05&#x2F;scrap-your-type-classes...</a>), but what&#x27;s really neat about Formality is that we can package propositions inside our &quot;class types&quot;, so that only lawful instances can be created.<p>For example, here&#x27;s our Semigroup type:<p><pre><code> T Semigroup {A : Type} | Semigroup { f : A -&gt; A -&gt; A , associative : Associative(A,f) } </code></pre> Where `Associative` is an abstract property defined in `Algebra.Magma` (<a href="https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Algebra.Magma.fm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Algebra...</a>)<p><pre><code> Associative : {A : Type, f : A -&gt; A -&gt; A} -&gt; Type {x : A, y : A, z : A} -&gt; f(f(x,y),z) == f(x,f(y,z)) </code></pre> Then if you want to instantiate a particular `Semigroup` you have to do:<p><pre><code> and.Semigroup : Semigroup(Bool) semigroup(~Bool, and, and.associative) and.associative : { case a : Bool , case b : Bool , case c : Bool } -&gt; and(and(a,b),c) == and(a,and(b,c)) | true true true =&gt; refl(~true) | true true false =&gt; refl(~false) | true false true =&gt; refl(~false) | true false false =&gt; refl(~false) | false true true =&gt; refl(~false) | false true false =&gt; refl(~false) | false false true =&gt; refl(~false) | false false false =&gt; refl(~false) </code></pre> Providing proofs all over the place is a lot of work, but it&#x27;s been a really fun experience that&#x27;s taught me a lot about different algebraic or category theoretic structures. Julie Moronuki&#x27;s post on [algebraic structures](<a href="https:&#x2F;&#x2F;argumatronic.com&#x2F;posts&#x2F;2019-06-21-algebra-cheatsheet.html" rel="nofollow">https:&#x2F;&#x2F;argumatronic.com&#x2F;posts&#x2F;2019-06-21-algebra-cheatsheet...</a>) has been an amazing resource.<p>Particular files in base that exemplify this are:<p>- Category.fm (<a href="https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Category.fm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Categor...</a>)<p>- Algebra.Lattice.fm (<a href="https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Algebra.Lattice.fm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Algebra...</a>)<p>- Control.Monad.fm (<a href="https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Control.Monad.fm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Control...</a>)<p>- Data.Maybe.Control (<a href="https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Data.Maybe.Control.fm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moonad&#x2F;Formality-Base&#x2F;blob&#x2F;master&#x2F;Data.Ma...</a>)<p>Still a ton of work to do, and a lot of these structures need instance proofs, so if anyone feels inspired, please don&#x27;t hesitate to join our Telegram channel (<a href="https:&#x2F;&#x2F;t.me&#x2F;formality_lang" rel="nofollow">https:&#x2F;&#x2F;t.me&#x2F;formality_lang</a>) or even DM me directly! (I&#x27;m @johnburnham on TG)<p>Comment adapted from a post on the Haskell subreddit: <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;haskell&#x2F;comments&#x2F;d2gcyw&#x2F;just_letting_you_know_that_formality_has_evolved&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;haskell&#x2F;comments&#x2F;d2gcyw&#x2F;just_lettin...</a>
评论 #20936628 未加载
评论 #20941782 未加载
评论 #20936836 未加载