Created
May 12, 2021 15:03
-
-
Save ebresafegaga/0b66ce802ed63d9909f7ff8465cc414d to your computer and use it in GitHub Desktop.
Recursive types in Typed Racket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(define-type Hungry (Rec X (Natural -> X))) | |
(: f Hungry) | |
(define (f _) f) | |
(define-type (Stream X) (Rec A (Void -> (List Natural A)))) | |
; U-combinator (self application) | |
(: U (∀ [T] (Rec X (X -> T)) -> T)) | |
(define (U f) (f f)) | |
; Y-combinator | |
(: fix (∀ [T] (T -> T) -> T)) | |
(define (fix f) | |
(U (λ ([x : (Rec A (A -> T))]) (f (x x))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment