Skip to content

RankNTypes issue #46

@iitalics

Description

@iitalics

Ran into an issue with the following (contrived) example:

(data Nop
  (nop (∀ [a] {a -> a})))
(defn ->nop : (∀ [a] {a -> Nop -> a})
  [[x (nop f)] (f x)])

The equivalent Haskell is:

data Nop = Nop (forall a. a -> a)
toNot :: a -> Nop -> a
toNot x (Nop f) = f x

Hackett complains with:

; a38218: skolem escaped its scope
;   in: a38218
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:113:4 simplify/elaborate
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:98:2 τs⇔/λ!
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:214:2 τ⇔/λ!
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:229:2 τ⇔!
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:238:2 τ⇐!
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:243:2
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:368:0
;  /home/milo/Git/hackett/hackett-lib/hackett/private/base.rkt:200:8 for-loop

Removing the outer quantification also throws the same error

(defn int-nop : {Nop -> Integer}
  [[(nop f)] (f 3)])

For some reason, Hackett really doesn't like using quantified types stored within data. The following does work:

(defn int-nop/fn : {(∀ [a] {a -> a}) -> Integer}
  [[f] (f 3)])

I'm going to guess this has something to do with unordered contexts, or maybe is just a small bug in the implementation. I'll take a look when I have some time

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions