File: Text.hs

package info (click to toggle)
haskell-inspection-testing 0.5.0.3-1
  • links: PTS
  • area: main
  • in suites: forky, trixie
  • size: 208 kB
  • sloc: haskell: 2,003; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE TemplateHaskell #-}
module Text (main) where

import Test.Inspection

import Data.Text as T
import Data.Text.Encoding as E
import Data.ByteString (ByteString)

-- Some cases of successful fusion:
toUpperString :: String -> String
toUpperString = T.unpack . T.toUpper . T.pack

toUpperBytestring :: ByteString -> String
toUpperBytestring = T.unpack . T.toUpper . E.decodeUtf8

-- This is the example from the text documentation.
-- Unfortunately it fails, the problem seems to be T.length.
countChars :: ByteString -> Int
countChars = T.length . T.toUpper . E.decodeUtf8

inspect $ 'toUpperString `hasNoType` ''T.Text
inspect $ 'toUpperBytestring `hasNoType` ''T.Text
inspect $ ('countChars `hasNoType` ''T.Text) { expectFail = True }

main :: IO ()
main = return ()