string-to-ascii-list function

This commit is contained in:
xenia 2023-09-09 12:57:04 +02:00
parent 6507dfe932
commit 1ff2708d6e
2 changed files with 4 additions and 1 deletions

View File

@ -59,6 +59,9 @@ string-to-ascii-list⁺ s {ascii} {nonempty} = vec-to-list⁺ v
v : Vec Byte (suc (pred (length s))) v : Vec Byte (suc (pred (length s)))
v = subst (λ x Vec Byte x) (sym (suc[pred[n]]≡n {length s} len≢0)) (string-to-ascii-vec s {ascii}) v = subst (λ x Vec Byte x) (sym (suc[pred[n]]≡n {length s} len≢0)) (string-to-ascii-vec s {ascii})
string-to-ascii-list : (s : String) {string-is-ascii s} List Byte
string-to-ascii-list s {ascii} = V.toList (string-to-ascii-vec s {ascii})
any-of : String [ Parser Byte ] any-of : String [ Parser Byte ]
any-of x = L.foldr (λ ch p ((_is ch) <?> any₁) <|> p) fail (S.toList x) any-of x = L.foldr (λ ch p ((_is ch) <?> any₁) <|> p) fail (S.toList x)

View File

@ -110,7 +110,7 @@ module Test-HTTP where
record { name = string-to-ascii-list⁺ "Content-Length" ; value = string-to-ascii-list⁺ "6" } record { name = string-to-ascii-list⁺ "Content-Length" ; value = string-to-ascii-list⁺ "6" }
List.∷ record { name = string-to-ascii-list⁺ "Host" ; value = string-to-ascii-list⁺ "agda.nu" } List.∷ record { name = string-to-ascii-list⁺ "Host" ; value = string-to-ascii-list⁺ "agda.nu" }
List.∷ List.[] List.∷ List.[]
; content = real (list⁺-to-list (string-to-ascii-list "mjau:)")) ; content = real (string-to-ascii-list "mjau:)")
} }
, _ , _
, enc "\r\n" , enc "\r\n"