on master help sign in
Added IsList instances for Data.Text, Data.Lazy.Text for GHC 7.8+

--HG-- extra : rebase_source : d1ed6b87ab814c8aae46ea5854e65a1af8f7dd97

commit8f1014292ffc2412186a1fd828c8b47423a87efe authorBaldur Blöndal <baldurpet@gmail.com> dateThu 3 Jul 2014, 05:36 (12 years ago) parent886af05
2 files changed+27−1
Data/Text.hs+13−1 Data/Text/Lazy.hs+14
Data/Text.hs+13−1
@@ -3,7 +3,9 @@
33#if __GLASGOW_HASKELL__ >= 702
44{-# LANGUAGE Trustworthy #-}
55#endif
6−{-# LANGUAGE MonoLocalBinds #-}
6+#if __GLASGOW_HASKELL__ >= 708
7+{-# LANGUAGE TypeFamilies #-}
8+#endif
79
810-- |
911-- Module : Data.Text
@@ -233,6 +235,9 @@ import qualified GHC.CString as GHC
233235#else
234236import qualified GHC.Base as GHC
235237#endif
238+#if __GLASGOW_HASKELL__ >= 708
239+import qualified GHC.Exts as Exts
240+#endif
236241import GHC.Prim (Addr#)
237242
238243-- $strict
@@ -333,6 +338,13 @@ instance Monoid Text where
333338instance IsString Text where
334339 fromString = pack
335340
341+#if __GLASGOW_HASKELL__ >= 708
342+instance Exts.IsList Text where
343+ type Item Text = Char
344+ fromList = pack
345+ toList = unpack
346+#endif
347+
336348#if defined(HAVE_DEEPSEQ)
337349instance NFData Text
338350#endif
Data/Text/Lazy.hs+14
@@ -3,6 +3,10 @@
33#if __GLASGOW_HASKELL__ >= 702
44{-# LANGUAGE Trustworthy #-}
55#endif
6+#if __GLASGOW_HASKELL__ >= 708
7+{-# LANGUAGE TypeFamilies #-}
8+#endif
9+
610-- |
711-- Module : Data.Text.Lazy
812-- Copyright : (c) 2009, 2010, 2012 Bryan O'Sullivan
@@ -223,6 +227,9 @@ import qualified GHC.CString as GHC
223227#else
224228import qualified GHC.Base as GHC
225229#endif
230+#if __GLASGOW_HASKELL__ >= 708
231+import qualified GHC.Exts as Exts
232+#endif
226233import GHC.Prim (Addr#)
227234
228235-- $fusion
@@ -329,6 +336,13 @@ instance Monoid Text where
329336instance IsString Text where
330337 fromString = pack
331338
339+#if __GLASGOW_HASKELL__ >= 708
340+instance Exts.IsList Text where
341+ type Item Text = Char
342+ fromList = pack
343+ toList = unpack
344+#endif
345+
332346#if defined(HAVE_DEEPSEQ)
333347instance NFData Text where
334348 rnf Empty = ()