From f2bae1a4010fb7e65d8dc14bfdead1506c11d97e Mon Sep 17 00:00:00 2001 From: Frankie Robertson <frankie@robertson.name> Date: Thu, 17 Dec 2015 20:50:46 +0200 Subject: [PATCH] Add IsString instance for UTF8 string container type --- Data/String/UTF8.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Data/String/UTF8.hs b/Data/String/UTF8.hs index a7a24f0..c67aae0 100644 --- a/Data/String/UTF8.hs +++ b/Data/String/UTF8.hs @@ -48,6 +48,7 @@ import Prelude hiding (null,take,drop,span,break ,foldl,foldr,length,lines,splitAt) import qualified Codec.Binary.UTF8.Generic as G import Codec.Binary.UTF8.Generic (UTF8Bytes) +import qualified Data.String as S -- | The type of strings that are represented using the UTF8 encoding. -- The parameter is the type of the container for the representation. @@ -56,6 +57,9 @@ newtype UTF8 string = Str string deriving (Eq,Ord) -- XXX: Is this OK? instance UTF8Bytes string index => Show (UTF8 string) where show x = show (toString x) +instance UTF8Bytes string index => S.IsString (UTF8 string) where + fromString = fromString + fromRep :: string -> UTF8 string fromRep = Str -- GitLab