Skip to content

Commit

Permalink
Add Into String instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Izaakwltn committed Oct 9, 2024
1 parent b75d02f commit 76fa2fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/cell.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
(define-instance (Into (Cell :a) :a)
(define into read))

(define-instance (Into :a String => Into (Cell :a) String)
(define (into c)
(into (read c))))

(define-instance (Default :a => Default (Cell :a))
(define (default) (new (default)))))

Expand Down
10 changes: 10 additions & 0 deletions library/string.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ does not have that suffix."
(lisp String (lst)
(cl:coerce lst 'cl:string))))

(define-instance (Into (List String) String)
(define (into strs)
(lisp String (strs)
(cl:format cl:nil "~{~a~}" strs))))

(define-instance (Into (Vector String) String)
(define (into strs)
(lisp String (strs)
(cl:format cl:nil "~{~a~}" (cl:coerce strs 'cl:list)))))

(define-instance (Iso (List Char) String)))

(define-instance-into-integral-string Integer)
Expand Down

0 comments on commit 76fa2fa

Please sign in to comment.