-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] use Data.String.Parser instead of Text.Parser for HTTPURL
- Loading branch information
1 parent
b0e07d9
commit 4587b14
Showing
9 changed files
with
123 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Network.URL.Internal.Predicate | ||
|
||
%default total | ||
|
||
-- 针对类型a的谓词 | ||
public export | ||
Predicate : Type -> Type | ||
Predicate a = a -> Bool | ||
|
||
-- 特别的,如果没有谓词,算是不通过 | ||
-- 任意一个通过,算是整体通过 | ||
public export | ||
anyPass : List (Predicate a) -> a -> Bool | ||
anyPass [] _ = False | ||
anyPass [p] x = p x | ||
anyPass (p :: ps) x = p x || anyPass ps x | ||
|
||
-- 特别的,如果没有谓词,算是不通过 | ||
-- 全部通过,才算是整体通过 | ||
public export | ||
allPass : List (Predicate a) -> a -> Bool | ||
allPass [] _ = False | ||
allPass [p] x = p x | ||
allPass (p :: ps) x = p x && allPass ps x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Network.URL.Internal.StringParser | ||
|
||
import Data.String.Parser | ||
import Data.String | ||
import Data.Fin | ||
|
||
export | ||
letters : Parser String | ||
letters = do | ||
chars <- some $ letter | ||
pure . joinBy "" . map Data.String.singleton $ chars | ||
|
||
export | ||
digits : Parser String | ||
digits = do | ||
ds <- some $ digit | ||
pure . joinBy "" . map show $ ds | ||
|
||
export | ||
int : Parser Int | ||
int = do | ||
ds <- digits | ||
pure $ cast ds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import Tester.Runner | |
|
||
import Network.URL.General | ||
|
||
|
||
-- 测试斜体 | ||
private | ||
testParser : List Test | ||
|
Oops, something went wrong.