Thanks to visit codestin.com
Credit goes to github.com

Skip to content

typechecker crash on omitted ability set #5025

@ceedubs

Description

@ceedubs

This is a fairly simple Stream.find implementation:

find :  (a -> {g} Boolean) -> '{g, Stream a} r -> Optional a
find f s =
  handle !s with cases
    { _ } -> None
    { emit a -> k } ->
      if f a then Some a else find f k

It results in the following:

  Sorry, you hit an error we didn't make a nice message for yet.

  Here is a summary of the Note:

    simple cause:
      TypeMismatch
    context:
    Γ
      |start1|
      |let-rec-marker2|
      |𝕩4|
      'Inference Ability-5
      'Inference Ability-77
      '𝕖78 = 𝕖5
      'User "g"-79
      '𝕖6 = 𝕖77, 𝕖5, g79
      find3 : (a ->{g} Boolean) ->{𝕖5} (Unit ->{g, Stream a} r) ->{𝕖77, 𝕖5, g79} Optional a
      |a8|
      @a9
      |g11|
      @g12
      |r14|
      @r15
      |a17|
      @a18
      |g20|
      @g21
      |r23|
      @r24
      |f26|
      f25 : a18 ->{g21} Boolean
      |s28|
      s27 : Unit ->{g21, Stream a18} r24
      '𝕧38 = r24
      'Inference Ability-41
      'e44 = a18
      '𝕗43 = Stream
      '𝕖42 = Stream a18
      '𝕦40 = 𝕖41, Stream a18
      '𝕗39 = Request
      '𝕗37 = Request {𝕖41, Stream a18}
      'vn6c9r3215130 = Request {𝕖41, Stream a18} r24
      '𝕖72 =
      '𝕖73 = 𝕖77, 𝕖5, g79
      '𝕖74 = 𝕖5
      'g75 = g21
      '𝕖31 = 𝕖77, 𝕖5, g79, 𝕖5, g21
      'a51 = a18
      '𝕗50 = Optional
      '𝕣32 = Optional a18
      vn6c9r3215129 : Request {𝕖41, Stream a18} r24
      'e33 = a18
      '𝕖35 = 𝕖41
      '𝕧34 = r24
      'Inference Ability-36
      'e71 = a18
      'Inference Ability-76

Simply adding a {g} in front of the result type avoids the crash, and the function works as expected:

find :  (a -> {g} Boolean) -> '{g, Stream a} r -> {g} Optional a
find f s =
  handle !s with cases
    { _ } -> None
    { emit a -> k } ->
      if f a then Some a else find f k

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions