Skip to content

Commit 5ac168f

Browse files
committed
Pull type querying into its own (file and) typeclass.
Why? Because checking types is restricted to rename-only substitutions (which the checker itself generates), but we want to be able to query types through a more meaningful substitution, such as the one carried by SimplifyM. Also, specializing the implementation to just querying lets us worry less about relying on laziness (in the HardFail monad) for performance. The ultimate purpose is to be able to (efficiently) query types in the input space of a pass (without having to subtitute the whole atom/expr/block first). This change reduces allocations on the kernel regression example by 6%, and improves runtime by about 2.5%.
1 parent 8e17301 commit 5ac168f

File tree

14 files changed

+669
-166
lines changed

14 files changed

+669
-166
lines changed

dex.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ library
8080
, Types.Imp
8181
, Types.Primitives
8282
, Types.Source
83+
, QueryType
8384
, Util
8485
if flag(live)
8586
exposed-modules: Actor

src/lib/Algebra.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Data.Coerce
2525
import Builder hiding (sub, add)
2626
import Simplify
2727
import Syntax
28-
import Type
28+
import QueryType
2929
import Name
3030
import Err
3131
import MTL1

src/lib/Builder.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import qualified RawName as R
6767
import Name
6868
import Syntax
6969
import Type
70+
import QueryType
7071
import PPrint (prettyBlock)
7172
import CheapReduction
7273
import {-# SOURCE #-} Inference

src/lib/Export.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import MTL1
1919
import Err
2020
import Syntax
2121
import Type
22+
import QueryType
2223
import Builder
2324
import Simplify
2425
import Imp

src/lib/Imp.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Syntax
3232
import Type
3333
import Simplify
3434
import LabeledItems
35+
import QueryType
3536
import Util (enumerate)
3637
import Types.Primitives
3738
import Algebra qualified as A

src/lib/Inference.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import Name
3535
import Builder
3636
import Syntax hiding (State)
3737
import Type
38+
import QueryType
3839
import PPrint (pprintCanonicalized, prettyBlock)
3940
import CheapReduction
4041
import GenericTraversal

src/lib/Interpreter.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Name
2828
import MTL1
2929
import Syntax
3030
import Simplify
31-
import Type
31+
import QueryType
3232
import PPrint ()
3333
import Util ((...))
3434

src/lib/Linearize.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Builder
1818
import Syntax
1919
import Type
2020
import MTL1
21+
import QueryType
2122
import Util (bindM2)
2223
import PPrint
2324

0 commit comments

Comments
 (0)