Skip to content
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1340085
[Homework01-Task4]:validate
cht8687 Aug 9, 2019
46b7705
merge
cht8687 Aug 14, 2019
683385a
Week2-Task1
cht8687 Aug 14, 2019
1663cb8
update
cht8687 Aug 15, 2019
2b4e59b
ViewPattern
cht8687 Aug 15, 2019
64eca0f
Merge remote-tracking branch 'upstream/master'
cht8687 Aug 16, 2019
38160c5
update readme
cht8687 Aug 17, 2019
1bd8a29
merge
cht8687 Aug 24, 2019
53720c1
task 1
cht8687 Aug 26, 2019
82f8c7a
Merge remote-tracking branch 'upstream/master'
cht8687 Aug 26, 2019
5a964e2
Task2
cht8687 Aug 28, 2019
d272163
merge
cht8687 Aug 28, 2019
2c5b76f
change names
cht8687 Aug 28, 2019
272c2f1
Merge remote-tracking branch 'upstream/master'
cht8687 Aug 31, 2019
b5c8116
[Week4]:Task1]
cht8687 Aug 31, 2019
a4b4b99
Task1-2nd solution
cht8687 Aug 31, 2019
ecb3165
update
cht8687 Aug 31, 2019
e6d24c3
[week4]Task3-1
cht8687 Sep 1, 2019
850701e
Merge remote-tracking branch 'upstream/master'
cht8687 Sep 8, 2019
696a0f8
Merge remote-tracking branch 'upstream/master'
cht8687 Sep 9, 2019
425a656
[Week5]T1,T2,T3,T4
cht8687 Sep 9, 2019
1181229
Merge remote-tracking branch 'upstream/master'
cht8687 Sep 16, 2019
e29d702
Week6-1,2,3,4
cht8687 Sep 22, 2019
26e6843
week6:task5
cht8687 Sep 25, 2019
08428e0
merge
cht8687 Sep 25, 2019
c681281
(week7):Task[1..2]
cht8687 Sep 29, 2019
ecbb6b4
Merge remote-tracking branch 'upstream/master'
cht8687 Sep 29, 2019
343c8fb
[week7]:Task2.2
cht8687 Oct 2, 2019
f47ed90
merge upstream
cht8687 Oct 2, 2019
0f0badb
(week7): Task2-3
cht8687 Oct 2, 2019
b16680d
merge
cht8687 Oct 2, 2019
0677ec9
refactored to shorter
cht8687 Oct 3, 2019
93d8835
WIP
cht8687 Oct 6, 2019
795bfe9
merge
cht8687 Oct 12, 2019
5ee541d
[Week10]: Task 1 -> Functor
cht8687 Oct 13, 2019
6628f9d
(week7)-task3
cht8687 Oct 13, 2019
7db4986
[week10]:Task2
cht8687 Oct 13, 2019
f2da9ba
remove duplicates
cht8687 Oct 14, 2019
09bfd21
Merge remote-tracking branch 'upstream/master'
cht8687 Oct 15, 2019
18ca0d4
Merge remote-tracking branch 'upstream/master'
cht8687 Oct 27, 2019
2620b11
(week10):task3-4
cht8687 Oct 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cis194/week10/haotian/src/AParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,22 @@ instance Applicative Parser where
case f s of
Nothing -> Nothing
Just (r, s') -> fmap (first r) . g $ s'

-- Ex. 3
abParser :: Parser (Char, Char)
abParser = (,) <$> char 'a' <*> char 'b'

abParser_ :: Parser ()
abParser_ = (\a b -> ()) <$> char 'a' <*> char 'b'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as @stevemao suggested before, can use void. Also can just reuse abParser.


intPair :: Parser [Integer]
intPair = (\x _ y -> [x, y]) <$> posInt <*> char ' ' <*> posInt

-- Ex. 4
instance Alternative Parser where
empty = Parser $ const Nothing
(Parser g) <|> (Parser f) = Parser $ \s -> (g s <|> f s)

intOrUppercase :: Parser ()
intOrUppercase =
((\x -> ()) <$> posInt) <|> ((\x -> ()) <$> satisfy (isUpper))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here could also apply void instead of (\x -> ()).