Skip to content

Commit d06d98f

Browse files
committed
Initial commit
0 parents  commit d06d98f

File tree

26 files changed

+4973
-0
lines changed

26 files changed

+4973
-0
lines changed

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright Neil Mitchell 2005-2020.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Neil Mitchell nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# OsString [![Hackage version](https://img.shields.io/hackage/v/os-string.svg?label=Hackage)](https://hackage.haskell.org/package/os-string)
2+
3+
This package provides functionality for manipulating @OsString@ values, and is shipped with <https://www.haskell.org/ghc/ GHC>.
4+

Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

System/OsString.hs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
-- |
2+
-- Module : OsString
3+
-- Copyright : © 2021 Julian Ospald
4+
-- License : MIT
5+
--
6+
-- Maintainer : Julian Ospald <[email protected]>
7+
-- Stability : experimental
8+
-- Portability : portable
9+
--
10+
-- An implementation of platform specific short 'OsString', which is:
11+
--
12+
-- 1. on windows wide char bytes (@[Word16]@)
13+
-- 2. on unix char bytes (@[Word8]@)
14+
--
15+
-- It captures the notion of syscall specific encoding (or the lack thereof) to avoid roundtrip issues
16+
-- and memory fragmentation by using unpinned byte arrays. Bytes are not touched or interpreted.
17+
module System.OsString
18+
(
19+
-- * String types
20+
OsString
21+
22+
-- * OsString construction
23+
, encodeUtf
24+
, encodeWith
25+
, encodeFS
26+
, osstr
27+
, empty
28+
, singleton
29+
, pack
30+
31+
-- * OsString deconstruction
32+
, decodeUtf
33+
, decodeWith
34+
, decodeFS
35+
, unpack
36+
37+
-- * Word types
38+
, OsChar
39+
40+
-- * Word construction
41+
, unsafeFromChar
42+
43+
-- * Word deconstruction
44+
, toChar
45+
46+
-- * Basic interface
47+
, snoc
48+
, cons
49+
, last
50+
, tail
51+
, uncons
52+
, head
53+
, init
54+
, unsnoc
55+
, null
56+
, length
57+
58+
-- * Transforming OsString
59+
, map
60+
, reverse
61+
, intercalate
62+
63+
-- * Reducing OsStrings (folds)
64+
, foldl
65+
, foldl'
66+
, foldl1
67+
, foldl1'
68+
, foldr
69+
, foldr'
70+
, foldr1
71+
, foldr1'
72+
73+
-- * Special folds
74+
, all
75+
, any
76+
, concat
77+
78+
-- * Generating and unfolding OsStrings
79+
, replicate
80+
, unfoldr
81+
, unfoldrN
82+
83+
-- * Substrings
84+
-- ** Breaking strings
85+
, take
86+
, takeEnd
87+
, takeWhileEnd
88+
, takeWhile
89+
, drop
90+
, dropEnd
91+
, dropWhileEnd
92+
, dropWhile
93+
, break
94+
, breakEnd
95+
, span
96+
, spanEnd
97+
, splitAt
98+
, split
99+
, splitWith
100+
, stripSuffix
101+
, stripPrefix
102+
103+
-- * Predicates
104+
, isInfixOf
105+
, isPrefixOf
106+
, isSuffixOf
107+
-- ** Search for arbitrary susbstrings
108+
, breakSubstring
109+
110+
-- * Searching OsStrings
111+
-- ** Searching by equality
112+
, elem
113+
, find
114+
, filter
115+
, partition
116+
117+
-- * Indexing OsStrings
118+
, index
119+
, indexMaybe
120+
, (!?)
121+
, elemIndex
122+
, elemIndices
123+
, count
124+
, findIndex
125+
, findIndices
126+
)
127+
where
128+
129+
import System.OsString.Internal
130+
( unsafeFromChar
131+
, toChar
132+
, encodeUtf
133+
, encodeWith
134+
, encodeFS
135+
, osstr
136+
, pack
137+
, empty
138+
, singleton
139+
, decodeUtf
140+
, decodeWith
141+
, decodeFS
142+
, unpack
143+
, snoc
144+
, cons
145+
, last
146+
, tail
147+
, uncons
148+
, head
149+
, init
150+
, unsnoc
151+
, null
152+
, length
153+
, map
154+
, reverse
155+
, intercalate
156+
, foldl
157+
, foldl'
158+
, foldl1
159+
, foldl1'
160+
, foldr
161+
, foldr'
162+
, foldr1
163+
, foldr1'
164+
, all
165+
, any
166+
, concat
167+
, replicate
168+
, unfoldr
169+
, unfoldrN
170+
, take
171+
, takeEnd
172+
, takeWhileEnd
173+
, takeWhile
174+
, drop
175+
, dropEnd
176+
, dropWhileEnd
177+
, dropWhile
178+
, break
179+
, breakEnd
180+
, span
181+
, spanEnd
182+
, splitAt
183+
, split
184+
, splitWith
185+
, stripSuffix
186+
, stripPrefix
187+
, isInfixOf
188+
, isPrefixOf
189+
, isSuffixOf
190+
, breakSubstring
191+
, elem
192+
, find
193+
, filter
194+
, partition
195+
, index
196+
, indexMaybe
197+
, (!?)
198+
, elemIndex
199+
, elemIndices
200+
, count
201+
, findIndex
202+
, findIndices
203+
)
204+
import System.OsString.Internal.Types
205+
( OsString, OsChar )
206+
import Prelude ()

0 commit comments

Comments
 (0)