File: Include.hs

package info (click to toggle)
haskell-path 0.9.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 432 kB
  • sloc: haskell: 3,246; makefile: 3
file content (139 lines) | stat: -rw-r--r-- 3,850 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
-- This template expects CPP definitions for:
--     PLATFORM_NAME = Posix | Windows
--     PLATFORM_STRING = PosixString | WindowsString
--     PLATFORM_CHAR = PosixChar | WindowsChar
--     IS_WINDOWS = 0 | 1

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving #-}

{-# OPTIONS_GHC -Wno-deprecations #-}
{-# OPTIONS_GHC -Wno-orphans #-}

#define USE_os_string 0
#if defined MIN_VERSION_os_string
#if MIN_VERSION_os_string(2,0,0)
#undef USE_os_string
#define USE_os_string 1
#endif
#endif

module System.OsString.Compat.PLATFORM_NAME
#if USE_os_string
  ( PLATFORM_STRING(..)
  , PLATFORM_CHAR(..)
  , module OsString
  )
#else
  ( PLATFORM_STRING(..)
  , PLATFORM_CHAR(..)
  , OsString.pstr
  , System.OsString.Compat.PLATFORM_NAME.all
  , System.OsString.Compat.PLATFORM_NAME.any
  , System.OsString.Compat.PLATFORM_NAME.break
  , System.OsString.Compat.PLATFORM_NAME.breakEnd
  , System.OsString.Compat.PLATFORM_NAME.dropWhileEnd
  , System.OsString.Compat.PLATFORM_NAME.empty
  , System.OsString.Compat.PLATFORM_NAME.init
  , System.OsString.Compat.PLATFORM_NAME.isInfixOf
  , System.OsString.Compat.PLATFORM_NAME.isPrefixOf
  , System.OsString.Compat.PLATFORM_NAME.isSuffixOf
  , System.OsString.Compat.PLATFORM_NAME.length
  , System.OsString.Compat.PLATFORM_NAME.map
  , System.OsString.Compat.PLATFORM_NAME.null
  , System.OsString.Compat.PLATFORM_NAME.replicate
  , System.OsString.Compat.PLATFORM_NAME.singleton
  , System.OsString.Compat.PLATFORM_NAME.span
  , System.OsString.Compat.PLATFORM_NAME.spanEnd
  , System.OsString.Compat.PLATFORM_NAME.stripPrefix
  , System.OsString.Compat.PLATFORM_NAME.uncons
  )
#endif
  where

import Data.Data (Data)
import System.OsString.Internal.Types (PLATFORM_STRING(..), PLATFORM_CHAR(..))
import System.OsString.PLATFORM_NAME as OsString

#if !USE_os_string
import Data.Coerce (coerce)

#if IS_WINDOWS
import qualified System.OsPath.Data.ByteString.Short.Word16 as BSP
#else
import qualified System.OsPath.Data.ByteString.Short as BSP
#endif
#endif

deriving instance Data PLATFORM_STRING

#if !USE_os_string
all :: (PLATFORM_CHAR -> Bool) -> PLATFORM_STRING -> Bool
all = coerce BSP.all

any :: (PLATFORM_CHAR -> Bool) -> PLATFORM_STRING -> Bool
any = coerce BSP.any

break
  :: (PLATFORM_CHAR -> Bool)
  -> PLATFORM_STRING
  -> (PLATFORM_STRING, PLATFORM_STRING)
break = coerce BSP.break

breakEnd
  :: (PLATFORM_CHAR -> Bool)
  -> PLATFORM_STRING
  -> (PLATFORM_STRING, PLATFORM_STRING)
breakEnd = coerce BSP.breakEnd

dropWhileEnd :: (PLATFORM_CHAR -> Bool) -> PLATFORM_STRING -> PLATFORM_STRING
dropWhileEnd = coerce BSP.dropWhileEnd

empty :: PLATFORM_STRING
empty = coerce BSP.empty

init :: PLATFORM_STRING -> PLATFORM_STRING
init = coerce BSP.init

isInfixOf :: PLATFORM_STRING -> PLATFORM_STRING -> Bool
isInfixOf = coerce BSP.isInfixOf

isPrefixOf :: PLATFORM_STRING -> PLATFORM_STRING -> Bool
isPrefixOf = coerce BSP.isPrefixOf

isSuffixOf :: PLATFORM_STRING -> PLATFORM_STRING -> Bool
isSuffixOf = coerce BSP.isSuffixOf

length :: PLATFORM_STRING -> Int
length = coerce BSP.length

map :: (PLATFORM_CHAR -> PLATFORM_CHAR) -> PLATFORM_STRING -> PLATFORM_STRING
map = coerce BSP.map

null :: PLATFORM_STRING -> Bool
null = coerce BSP.null

replicate :: Int -> PLATFORM_CHAR -> PLATFORM_STRING
replicate = coerce BSP.replicate

singleton :: PLATFORM_CHAR -> PLATFORM_STRING
singleton = coerce BSP.singleton

span
  :: (PLATFORM_CHAR -> Bool)
  -> PLATFORM_STRING
  -> (PLATFORM_STRING, PLATFORM_STRING)
span = coerce BSP.span

spanEnd
  :: (PLATFORM_CHAR -> Bool)
  -> PLATFORM_STRING
  -> (PLATFORM_STRING, PLATFORM_STRING)
spanEnd = coerce BSP.spanEnd

stripPrefix :: PLATFORM_STRING -> PLATFORM_STRING -> Maybe PLATFORM_STRING
stripPrefix = coerce BSP.stripPrefix

uncons :: PLATFORM_STRING -> Maybe (PLATFORM_CHAR, PLATFORM_STRING)
uncons = coerce BSP.uncons
#endif