Skip to content

Commit

Permalink
Add a canonical Char→String function and Cast instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Melvar committed Nov 14, 2013
1 parent 9449751 commit 968d433
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Prelude/Strings.idr
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ unpack s with (strM s)
pack : (Foldable t) => t Char -> String
pack = foldr strCons ""

singleton : Char -> String
singleton c = strCons c ""

instance Cast String (List Char) where
cast = unpack

instance Cast (List Char) String where
cast = pack

instance Cast Char String where
cast = singleton

instance Semigroup String where
(<+>) = (++)

Expand Down

0 comments on commit 968d433

Please sign in to comment.