Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
filepath
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Haskell
filepath
Commits
06823025
Unverified
Commit
06823025
authored
1 year ago
by
Julian Ospald
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'github/pr/210'
parents
b55465e3
229fdb34
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
System/OsPath/Internal.hs
+16
-9
16 additions, 9 deletions
System/OsPath/Internal.hs
with
16 additions
and
9 deletions
System/OsPath/Internal.hs
+
16
−
9
View file @
06823025
{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE ViewPatterns #-}
-- needed to quote a view pattern
module
System.OsPath.Internal
where
...
...
@@ -111,7 +113,8 @@ fromBytes = OS.fromBytes
-- | QuasiQuote an 'OsPath'. This accepts Unicode characters
-- and encodes as UTF-8 on unix and UTF-16LE on windows. Runs 'isValid'
-- on the input.
-- on the input. If used as a pattern, requires turning on the @ViewPatterns@
-- extension.
osp
::
QuasiQuoter
osp
=
QuasiQuoter
#
if
defined
(
mingw32_HOST_OS
)
||
defined
(
__MINGW32__
)
...
...
@@ -119,24 +122,28 @@ osp = QuasiQuoter
osp'
<-
either
(
fail
.
show
)
(
pure
.
OsString
)
.
PF
.
encodeWith
(
mkUTF16le
ErrorOnCodingFailure
)
$
s
when
(
not
$
isValid
osp'
)
$
fail
(
"filepath not valid: "
++
show
osp'
)
lift
osp'
,
quotePat
=
\
_
->
fail
"illegal QuasiQuote (allowed as expression only, used as a pattern)"
,
quotePat
=
\
s
->
do
osp'
<-
either
(
fail
.
show
)
(
pure
.
OsString
)
.
PF
.
encodeWith
(
mkUTF16le
ErrorOnCodingFailure
)
$
s
when
(
not
$
isValid
osp'
)
$
fail
(
"filepath not valid: "
++
show
osp'
)
[
p
|
((==) osp' -> True)
|]
,
quoteType
=
\
_
->
fail
"illegal QuasiQuote (allowed as expression only, used as a type)"
fail
"illegal QuasiQuote (allowed as expression
or pattern
only, used as a type)"
,
quoteDec
=
\
_
->
fail
"illegal QuasiQuote (allowed as expression only, used as a declaration)"
fail
"illegal QuasiQuote (allowed as expression
or pattern
only, used as a declaration)"
}
#
else
{
quoteExp
=
\
s
->
do
osp'
<-
either
(
fail
.
show
)
(
pure
.
OsString
)
.
PF
.
encodeWith
(
mkUTF8
ErrorOnCodingFailure
)
$
s
when
(
not
$
isValid
osp'
)
$
fail
(
"filepath not valid: "
++
show
osp'
)
lift
osp'
,
quotePat
=
\
_
->
fail
"illegal QuasiQuote (allowed as expression only, used as a pattern)"
,
quotePat
=
\
s
->
do
osp'
<-
either
(
fail
.
show
)
(
pure
.
OsString
)
.
PF
.
encodeWith
(
mkUTF8
ErrorOnCodingFailure
)
$
s
when
(
not
$
isValid
osp'
)
$
fail
(
"filepath not valid: "
++
show
osp'
)
[
p
|
((==) osp' -> True)
|]
,
quoteType
=
\
_
->
fail
"illegal QuasiQuote (allowed as expression only, used as a type)"
fail
"illegal QuasiQuote (allowed as expression
or pattern
only, used as a type)"
,
quoteDec
=
\
_
->
fail
"illegal QuasiQuote (allowed as expression only, used as a declaration)"
fail
"illegal QuasiQuote (allowed as expression
or pattern
only, used as a declaration)"
}
#
endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment