4
4
{-# LANGUAGE OverloadedStrings #-}
5
5
{-# LANGUAGE RankNTypes #-}
6
6
{-# LANGUAGE ScopedTypeVariables #-}
7
- {-# LANGUAGE TemplateHaskell #-}
8
7
{-# LANGUAGE TupleSections #-}
9
8
10
9
module Codec.Xlsx.Types.Common
@@ -75,6 +74,8 @@ import Data.Function ((&))
75
74
import Data.Ix (inRange )
76
75
import qualified Data.Map as Map
77
76
import Data.Maybe (fromMaybe , isJust )
77
+ import Data.Profunctor (dimap )
78
+ import Data.Profunctor.Choice
78
79
import Data.Text (Text )
79
80
import qualified Data.Text as T
80
81
import qualified Data.Text.Encoding as T
@@ -88,8 +89,6 @@ import Text.XML.Cursor
88
89
import Lens.Micro
89
90
import Lens.Micro.Internal
90
91
import Lens.Micro.GHC ()
91
- import Data.Profunctor.Choice
92
- import Data.Profunctor (dimap )
93
92
#else
94
93
import Control.Lens (makePrisms )
95
94
#endif
@@ -670,77 +669,85 @@ instance ToAttrVal ErrorType where
670
669
toAttrVal ErrorRef = " #REF!"
671
670
toAttrVal ErrorValue = " #VALUE!"
672
671
673
- #ifdef USE_MICROLENS
674
672
-- Since micro-lens denies the existence of prisms,
675
673
-- I pasted the splice that's generated from makePrisms,
676
674
-- then I copied over the definitions from Control.Lens for the prism
677
675
-- function as well.
678
676
-- Essentially this is doing the template haskell by hand.
679
- type Prism s t a b = forall p f . (Choice p , Applicative f ) = > p a (f b ) -> p s (f t )
677
+ type Prism s t a b =
678
+ forall p f . (Choice p , Applicative f ) = > p a (f b ) -> p s (f t )
679
+
680
680
type Prism' s a = Prism s s a a
681
681
682
682
prism :: (b -> t ) -> (s -> Either t a ) -> Prism s t a b
683
683
prism bt seta = dimap seta (either pure (fmap bt)) . right'
684
684
685
685
_CellText :: Prism' CellValue Text
686
- _CellText
687
- = (prism (\ x1_a1ZQv -> CellText x1_a1ZQv))
688
- (\ x_a1ZQw
689
- -> case x_a1ZQw of
690
- CellText y1_a1ZQx -> Right y1_a1ZQx
691
- _ -> Left x_a1ZQw)
686
+ _CellText =
687
+ (prism (\ x1_a1ZQv -> CellText x1_a1ZQv))
688
+ ( \ x_a1ZQw ->
689
+ case x_a1ZQw of
690
+ CellText y1_a1ZQx -> Right y1_a1ZQx
691
+ _ -> Left x_a1ZQw
692
+ )
692
693
{-# INLINE _CellText #-}
694
+
693
695
_CellDouble :: Prism' CellValue Double
694
- _CellDouble
695
- = (prism (\ x1_a1ZQy -> CellDouble x1_a1ZQy))
696
- (\ x_a1ZQz
697
- -> case x_a1ZQz of
698
- CellDouble y1_a1ZQA -> Right y1_a1ZQA
699
- _ -> Left x_a1ZQz)
696
+ _CellDouble =
697
+ (prism (\ x1_a1ZQy -> CellDouble x1_a1ZQy))
698
+ ( \ x_a1ZQz ->
699
+ case x_a1ZQz of
700
+ CellDouble y1_a1ZQA -> Right y1_a1ZQA
701
+ _ -> Left x_a1ZQz
702
+ )
700
703
{-# INLINE _CellDouble #-}
704
+
701
705
_CellBool :: Prism' CellValue Bool
702
- _CellBool
703
- = (prism (\ x1_a1ZQB -> CellBool x1_a1ZQB))
704
- (\ x_a1ZQC
705
- -> case x_a1ZQC of
706
- CellBool y1_a1ZQD -> Right y1_a1ZQD
707
- _ -> Left x_a1ZQC)
706
+ _CellBool =
707
+ (prism (\ x1_a1ZQB -> CellBool x1_a1ZQB))
708
+ ( \ x_a1ZQC ->
709
+ case x_a1ZQC of
710
+ CellBool y1_a1ZQD -> Right y1_a1ZQD
711
+ _ -> Left x_a1ZQC
712
+ )
708
713
{-# INLINE _CellBool #-}
714
+
709
715
_CellRich :: Prism' CellValue [RichTextRun ]
710
- _CellRich
711
- = (prism (\ x1_a1ZQE -> CellRich x1_a1ZQE))
712
- (\ x_a1ZQF
713
- -> case x_a1ZQF of
714
- CellRich y1_a1ZQG -> Right y1_a1ZQG
715
- _ -> Left x_a1ZQF)
716
+ _CellRich =
717
+ (prism (\ x1_a1ZQE -> CellRich x1_a1ZQE))
718
+ ( \ x_a1ZQF ->
719
+ case x_a1ZQF of
720
+ CellRich y1_a1ZQG -> Right y1_a1ZQG
721
+ _ -> Left x_a1ZQF
722
+ )
716
723
{-# INLINE _CellRich #-}
724
+
717
725
_CellError :: Prism' CellValue ErrorType
718
- _CellError
719
- = (prism (\ x1_a1ZQH -> CellError x1_a1ZQH))
720
- (\ x_a1ZQI
721
- -> case x_a1ZQI of
722
- CellError y1_a1ZQJ -> Right y1_a1ZQJ
723
- _ -> Left x_a1ZQI)
726
+ _CellError =
727
+ (prism (\ x1_a1ZQH -> CellError x1_a1ZQH))
728
+ ( \ x_a1ZQI ->
729
+ case x_a1ZQI of
730
+ CellError y1_a1ZQJ -> Right y1_a1ZQJ
731
+ _ -> Left x_a1ZQI
732
+ )
724
733
{-# INLINE _CellError #-}
725
734
726
735
_XlsxText :: Prism' XlsxText Text
727
- _XlsxText
728
- = (prism (\ x1_a1ZzU -> XlsxText x1_a1ZzU))
729
- (\ x_a1ZzV
730
- -> case x_a1ZzV of
731
- XlsxText y1_a1ZzW -> Right y1_a1ZzW
732
- _ -> Left x_a1ZzV)
736
+ _XlsxText =
737
+ (prism (\ x1_a1ZzU -> XlsxText x1_a1ZzU))
738
+ ( \ x_a1ZzV ->
739
+ case x_a1ZzV of
740
+ XlsxText y1_a1ZzW -> Right y1_a1ZzW
741
+ _ -> Left x_a1ZzV
742
+ )
733
743
{-# INLINE _XlsxText #-}
744
+
734
745
_XlsxRichText :: Prism' XlsxText [RichTextRun ]
735
- _XlsxRichText
736
- = (prism (\ x1_a1ZzX -> XlsxRichText x1_a1ZzX))
737
- (\ x_a1ZzY
738
- -> case x_a1ZzY of
739
- XlsxRichText y1_a1ZzZ -> Right y1_a1ZzZ
740
- _ -> Left x_a1ZzY)
746
+ _XlsxRichText =
747
+ (prism (\ x1_a1ZzX -> XlsxRichText x1_a1ZzX))
748
+ ( \ x_a1ZzY ->
749
+ case x_a1ZzY of
750
+ XlsxRichText y1_a1ZzZ -> Right y1_a1ZzZ
751
+ _ -> Left x_a1ZzY
752
+ )
741
753
{-# INLINE _XlsxRichText #-}
742
-
743
- #else
744
- makePrisms ''XlsxText
745
- makePrisms ''CellValue
746
- #endif
0 commit comments