Skip to content

Commit 7ad99f6

Browse files
authored
Merge pull request #203 from carymrobbins/fix-non-terminating-const
2 parents cc36b29 + 3c3646a commit 7ad99f6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Data/Csv/Conversion.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ instance ToField a => ToField (Identity a) where
811811

812812
-- | @since 0.5.2.0
813813
instance FromField a => FromField (Const a b) where
814-
parseField = fmap getConst . parseField
814+
parseField = fmap Const . parseField
815815
{-# INLINE parseField #-}
816816

817817
-- | @since 0.5.2.0

tests/UnitTests.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE CPP, DeriveGeneric, OverloadedStrings, ScopedTypeVariables #-}
1+
{-# LANGUAGE CPP, DataKinds, DeriveGeneric, OverloadedStrings, ScopedTypeVariables #-}
22

33
#if __GLASGOW_HASKELL__ >= 801
44
{-# OPTIONS_GHC -Wno-orphans -Wno-unused-top-binds #-}
@@ -10,6 +10,7 @@ module Main
1010
( main
1111
) where
1212

13+
import Control.Applicative (Const)
1314
import qualified Data.ByteString as B
1415
import qualified Data.ByteString.Lazy as BL
1516
import qualified Data.ByteString.Lazy.Char8 as BL8
@@ -303,6 +304,15 @@ conversionTests =
303304
(roundTrip :: BL.ByteString -> Bool)
304305
, testProperty "Text" (roundTrip :: T.Text -> Bool)
305306
, testProperty "lazy Text" (roundTrip :: LT.Text -> Bool)
307+
308+
#if __GLASGOW_HASKELL__ >= 800
309+
-- Using DataKinds here to prove that our Const instance is polykinded.
310+
, testProperty "Const Char" (roundTrip :: Const Char "" -> Bool)
311+
#else
312+
-- For lower GHC versions, Const does not support PolyKinds.
313+
, testProperty "Const Char" (roundTrip :: Const Char () -> Bool)
314+
#endif
315+
306316
]
307317
, testGroup "boundary"
308318
[ testProperty "Int" (boundary (undefined :: Int))

0 commit comments

Comments
 (0)