Skip to content

Implementing a type checker for Hull#368

Merged
rodrigogribeiro merged 9 commits into
mainfrom
hull-typechecker
May 6, 2026
Merged

Implementing a type checker for Hull#368
rodrigogribeiro merged 9 commits into
mainfrom
hull-typechecker

Conversation

@rodrigogribeiro

Copy link
Copy Markdown
Collaborator
  • This PR introduces a type checker for Hull into Yule.
  • Adds test cases for simple Hull programs that are accepted and rejected by the type checker.

* Includes a typechecker for hull in Yule.
* Adds test cases for the typechecker.

@mbenke mbenke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, just some minor issues.

Comment thread src/Language/Hull/TcEnv.hs Outdated
Comment thread src/Language/Hull/TcEnv.hs
Comment thread src/Language/Hull/TypeCheck.hs Outdated
rodrigogribeiro and others added 4 commits May 6, 2026 08:10
Co-authored-by: Marcin Benke <marcin.benke@argot.org>
Co-authored-by: Marcin Benke <marcin.benke@argot.org>
Co-authored-by: Marcin Benke <marcin.benke@argot.org>
@mbenke

mbenke commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Actually there is a problem with this weird code:

object Unsafe {
  code {
    function fromWord$unit (x : word) -> unit {
      let result : unit
      assembly {
        result := x
      }
      return result
    }
    function main () -> word {
      fromWord$unit(7)
      return 42
    }
  }
}

in checkAsmStmt:

  • mapM_ (lookupVar . show) ns verifies result exists and retrieves its type TUnit, but immediately discards it. Only existence is checked.
  • nExpected = length ns = 1 This counts variable names, not slots. result : unit occupies 0 slots, so the expected count should be returnCount TUnit = 0. But the code never looks at the LHS types. - nActual = returnCount TWord = 1.

Comment thread src/Language/Hull/TypeCheck.hs
Co-authored-by: Marcin Benke <marcin.benke@argot.org>
@rodrigogribeiro rodrigogribeiro merged commit 015915f into main May 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants