Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exhaustiveness checking for non-arithmetic patterns #434

Merged
merged 45 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1a91697
hook into eval and build guard tree
LeitMoth Jul 11, 2024
d1a0c34
massive mess, decided to keep around my own TypeInfo
LeitMoth Jul 15, 2024
c6ab201
port over inhabpat generation + mostly finish up TypeInfo. constraint…
LeitMoth Jul 16, 2024
86190d3
kind of works, pairs super broken
LeitMoth Jul 18, 2024
fe5da67
tuples now turn into pairs and work! (mostly. Found weeks old bug in …
LeitMoth Jul 18, 2024
c7ba83e
remove old typeinfo doc, add fixme note about pair / order based bug
LeitMoth Jul 18, 2024
7c65f3e
fix term equality bug, I just had things backwards
LeitMoth Jul 19, 2024
4bb13fa
lists & strings work now! Added comments about remaining work
LeitMoth Jul 20, 2024
965cc73
remove unused lit variants T/F, improve warning message
LeitMoth Jul 20, 2024
f2dd479
sum types now work!
LeitMoth Jul 20, 2024
03e051a
User defined types now work!
LeitMoth Jul 20, 2024
cbde20e
Create differen inhab fn to find 3 positive examples only, more nuanc…
LeitMoth Jul 26, 2024
d7bc449
use Output Messages / limit depth of example-finding to stop infinite…
LeitMoth Jul 31, 2024
4e6c24d
Fix bug, now we get the Tydefs from the correct location
LeitMoth Aug 15, 2024
d291563
Fix bug cause by previous fix, now we merge both repl and module tydefs
LeitMoth Aug 15, 2024
6ac776c
mid refactor - all tests pass!
LeitMoth Aug 15, 2024
5bd7d59
add integers + small cleanup
LeitMoth Aug 15, 2024
ee39666
resugar truples and lists + use prettyprinter to better display output
LeitMoth Sep 21, 2024
66be013
add credit for infinite list of integers
LeitMoth Jan 2, 2025
8683dd8
add more TODOs
LeitMoth Jan 2, 2025
e64c829
apply all lsp hints on my files
LeitMoth Jan 9, 2025
23e1775
remove old prettyrprint and rename new prettyprint
LeitMoth Jan 9, 2025
5d6ffad
tweak desugarMatch and update comment
LeitMoth Jan 9, 2025
89f0987
update comments in typeinfo
LeitMoth Jan 9, 2025
ad5d6a9
add more todo comments
LeitMoth Jan 9, 2025
8737963
refactor context to set
LeitMoth Jan 9, 2025
4cc31de
remove redundant Context from Nref
LeitMoth Jan 9, 2025
16f4e33
Fix typo in Constraint.hs
LeitMoth Jan 9, 2025
c4c88bc
small doc cleanup
LeitMoth Jan 9, 2025
7d0716f
update desugarMatch documentation
LeitMoth Jan 9, 2025
ed831fe
simplify possibilities by deriving everything
LeitMoth Jan 10, 2025
516cb46
add comment and link to LYG paper on checkClauses function
LeitMoth Jan 16, 2025
6d49bbc
rephrase warning message
LeitMoth Jan 16, 2025
7a036e6
comment on resolveAlias why infinite recursion is impossible
LeitMoth Jan 16, 2025
d9d3169
remove unneeded comments about type constraints; I got confirmation r…
LeitMoth Jan 16, 2025
c22b1d3
list all unicode characters as constructors for Char (alphanumeric th…
LeitMoth Jan 16, 2025
02611f6
remove outdated example/lists.disco
LeitMoth Jan 18, 2025
f03bce7
make chars all unicode but ordered nicely
LeitMoth Jan 19, 2025
b65c89f
consolidate doc comment for tyDataConsHelper
LeitMoth Jan 19, 2025
c6e2d65
fix typo in KUnknown
LeitMoth Jan 19, 2025
d1fb240
add Haddock module comments
LeitMoth Jan 19, 2025
653737e
remove old typeinfo comment
LeitMoth Jan 19, 2025
565da27
convert back to patterns and use disco pretty printing
LeitMoth Jan 20, 2025
996d74b
Restyled by fourmolu (#435)
github-actions[bot] Jan 21, 2025
91507d5
Merge branch 'main' into exhaustiveness
mergify[bot] Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions disco.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ library
Disco.Value
Disco.Error
Disco.Eval
Disco.Exhaustiveness
Disco.Exhaustiveness.Constraint
Disco.Exhaustiveness.Possibilities
Disco.Exhaustiveness.TypeInfo
Disco.Interpret.CESK
Disco.Subst
Disco.Typecheck
Expand Down
12 changes: 0 additions & 12 deletions example/lists.disco

This file was deleted.

3 changes: 3 additions & 0 deletions src/Disco/AST/Surface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ module Disco.AST.Surface (
pattern PFrac,
pattern PNonlinear,
pattern Binding,

-- ** Pretty printing
prettyPatternP,
)
where

Expand Down
11 changes: 11 additions & 0 deletions src/Disco/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ import Polysemy.Output
import Polysemy.Random
import Polysemy.Reader

import qualified Data.List.NonEmpty as NonEmpty
import Disco.AST.Core
import Disco.AST.Surface
import Disco.Compile (compileDefns)
import Disco.Context as Ctx
import Disco.Error
import Disco.Exhaustiveness (checkClauses)
import Disco.Extensions
import Disco.Interpret.CESK
import Disco.Messages
Expand Down Expand Up @@ -384,6 +386,10 @@ loadParsedDiscoModule' quiet mode resolver inProcess name cm@(Module _ mns _ _ _
-- Typecheck (and resolve names in) the module.
m <- runTCM tyctx tydefns $ checkModule name importMap cm

-- Check for partial functions
let allTyDefs = M.unionWith const tydefns (m ^. miTydefs)
runFresh $ mapM_ (checkExhaustive allTyDefs) (Ctx.elems $ m ^. miTermdefs)

-- Evaluate all the module definitions and add them to the topEnv.
mapError EvalErr $ loadDefsFrom m

Expand Down Expand Up @@ -443,3 +449,8 @@ loadDef ::
loadDef x body = do
v <- inputToState @TopInfo . inputTopEnv $ eval body
modify @TopInfo $ topEnv %~ Ctx.insert x v

checkExhaustive :: Members '[Fresh, Output (Message ann), Embed IO] r => TyDefCtx -> Defn -> Sem r ()
checkExhaustive tyDefCtx (Defn name argsType _ boundClauses) = do
clauses <- NonEmpty.map fst <$> mapM unbind boundClauses
runReader @TyDefCtx tyDefCtx $ checkClauses name argsType clauses
Loading
Loading