Split Path type into Path and OtherSystemPath.
This commit is contained in:
parent
8f6d3c7920
commit
05af2b9e17
27
collects/tests/typed-scheme/succeed/somesystempath.rkt
Normal file
27
collects/tests/typed-scheme/succeed/somesystempath.rkt
Normal file
|
@ -0,0 +1,27 @@
|
|||
#lang typed/racket
|
||||
|
||||
(: unix-path SomeSystemPath)
|
||||
(define unix-path (string->some-system-path "file.rkt" 'unix))
|
||||
|
||||
(: windows-path SomeSystemPath)
|
||||
(define windows-path (string->some-system-path "file.rkt" 'windows))
|
||||
|
||||
(for: ((p : SomeSystemPath (list unix-path windows-path)))
|
||||
(let ((long-path (build-path p 'up 'same p)))
|
||||
(unless (path-for-some-system? p)
|
||||
(error "Predicate failed"))
|
||||
(explode-path long-path)
|
||||
|
||||
(filename-extension p)
|
||||
(path-only long-path)
|
||||
(some-system-path->string long-path)
|
||||
|
||||
))
|
||||
|
||||
|
||||
(when (equal? 'unix (system-path-convention-type))
|
||||
(find-relative-path (simplify-path (path->complete-path "foo")) (simplify-path (path->complete-path "foo/foo/foo"))))
|
||||
|
||||
|
||||
|
||||
|
|
@ -394,7 +394,7 @@
|
|||
[string->path (-> -String -Path)]
|
||||
|
||||
|
||||
[build-path ((list -Pathlike*) -Pathlike* . ->* . -Path)]
|
||||
[build-path ((list -SomeSystemPathlike*) -SomeSystemPathlike* . ->* . -Path)]
|
||||
[with-input-from-file
|
||||
(-poly (a) (->key -Pathlike (-> a) #:mode (one-of/c 'binary 'text) #f a))]
|
||||
[with-output-to-file
|
||||
|
@ -750,6 +750,7 @@
|
|||
[object-name (Univ . -> . Univ)]
|
||||
|
||||
[path? (make-pred-ty -Path)]
|
||||
[path-for-some-system? (make-pred-ty -SomeSystemPath)]
|
||||
|
||||
;; scheme/function
|
||||
[const (-poly (a) (-> a (->* '() Univ a)))]
|
||||
|
@ -843,16 +844,23 @@
|
|||
|
||||
;; scheme/path
|
||||
|
||||
[explode-path (-Pathlike . -> . (-lst (Un -Path (-val 'up) (-val 'same))))]
|
||||
[find-relative-path (-Pathlike -Pathlike . -> . -Path)]
|
||||
[explode-path (-SomeSystemPathlike . -> . (-lst (Un -SomeSystemPath (-val 'up) (-val 'same))))]
|
||||
[find-relative-path (-SomeSystemPathlike -SomeSystemPathlike . -> . -SomeSystemPath)]
|
||||
[simple-form-path (-Pathlike . -> . -Path)]
|
||||
[normalize-path (cl->* (-Pathlike [-Pathlike] . ->opt . -Path))]
|
||||
[filename-extension (-Pathlike . -> . (-opt -Bytes))]
|
||||
[filename-extension (-SomeSystemPathlike . -> . (-opt -Bytes))]
|
||||
[file-name-from-path (-Pathlike . -> . (-opt -Path))]
|
||||
[path-only (-Pathlike . -> . (-opt -Path))]
|
||||
[some-system-path->string (-Path . -> . -String)]
|
||||
[path-only (-SomeSystemPathlike . -> . (-opt -Path))]
|
||||
[some-system-path->string (-SomeSystemPath . -> . -String)]
|
||||
[string->some-system-path
|
||||
(-String (Un (-val 'unix) (-val 'windows)) . -> . -Path)]
|
||||
(-String (Un (-val 'unix) (-val 'windows)) . -> . -SomeSystemPath)]
|
||||
|
||||
[simplify-path (-SomeSystemPathlike [B] . ->opt . -SomeSystemPath)]
|
||||
[path->complete-path
|
||||
(cl->* (-> -Pathlike -Path)
|
||||
(-> -SomeSystemPathlike -SomeSystemPathlike -SomeSystemPath))]
|
||||
[system-path-convention-type (-> (Un (-val 'unix) (-val 'windows)))]
|
||||
|
||||
|
||||
;; scheme/file
|
||||
[fold-files
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
[Any Univ]
|
||||
[Port -Port]
|
||||
[Path -Path]
|
||||
[SomeSystemPath -SomeSystemPath]
|
||||
[Path-String -Pathlike]
|
||||
[Regexp -Regexp]
|
||||
[PRegexp -PRegexp]
|
||||
|
|
|
@ -143,6 +143,10 @@
|
|||
(define -Prompt-Tag (make-Base 'Prompt-Tag #'continuation-prompt-tag? continuation-prompt-tag? #'-Prompt-Tag))
|
||||
(define -Cont-Mark-Set (make-Base 'Continuation-Mark-Set #'continuation-mark-set? continuation-mark-set? #'-Cont-Mark-Set))
|
||||
(define -Path (make-Base 'Path #'path? path? #'-Path))
|
||||
(define -OtherSystemPath (make-Base 'OtherSystemPath
|
||||
#'(and/c path-for-some-system? (not/c path?))
|
||||
(conjoin path-for-some-system? (negate path?))
|
||||
#'-OtherSystemPath))
|
||||
(define -Namespace (make-Base 'Namespace #'namespace? namespace? #'-Namespace))
|
||||
(define -Output-Port (make-Base 'Output-Port #'output-port? output-port? #'-Output-Port))
|
||||
(define -Input-Port (make-Base 'Input-Port #'input-port? input-port? #'-Input-Port))
|
||||
|
@ -159,8 +163,11 @@
|
|||
|
||||
(define -Port (*Un -Output-Port -Input-Port))
|
||||
|
||||
(define -SomeSystemPath (*Un -Path -OtherSystemPath))
|
||||
(define -Pathlike (*Un -String -Path))
|
||||
(define -Pathlike* (*Un -String -Path (-val 'up) (-val 'same)))
|
||||
(define -SomeSystemPathlike (*Un -String -SomeSystemPath))
|
||||
;(define -Pathlike* (*Un -String -Path (-val 'up) (-val 'same)))
|
||||
(define -SomeSystemPathlike* (*Un -String -SomeSystemPath(-val 'up) (-val 'same)))
|
||||
(define -Pattern (*Un -Bytes -Regexp -PRegexp -Byte-Regexp -Byte-PRegexp -String))
|
||||
|
||||
(define -top (make-Top))
|
||||
|
|
Loading…
Reference in New Issue
Block a user