Blah
parent
57dfaef8a4
commit
96103ea665
|
@ -42,12 +42,18 @@ instance bindParser :: Bind Parser where
|
||||||
let (Parser p2) = f x
|
let (Parser p2) = f x
|
||||||
in p2 xs
|
in p2 xs
|
||||||
|
|
||||||
|
charP :: Char -> Parser Boolean
|
||||||
|
charP c = (_ == c) <$> itemP
|
||||||
|
|
||||||
isf :: Parser Boolean
|
isf :: Parser Boolean
|
||||||
isf = (_ == 'f') <$> itemP
|
isf = (_ == 'f') <$> itemP
|
||||||
|
|
||||||
isf2 :: Parser Boolean
|
isf2 :: Parser Boolean
|
||||||
isf2 = (==) <$> itemP <*> pure 'f'
|
isf2 = (==) <$> itemP <*> pure 'f'
|
||||||
|
|
||||||
|
isf3 :: Parser Boolean
|
||||||
|
isf3 = charP 'f'
|
||||||
|
|
||||||
ishi :: Parser (Tuple Boolean Boolean)
|
ishi :: Parser (Tuple Boolean Boolean)
|
||||||
ishi = Tuple <$> ((_ == 'h') <$> itemP) <*> ((_ == 'i') <$> itemP)
|
ishi = Tuple <$> ((_ == 'h') <$> itemP) <*> ((_ == 'i') <$> itemP)
|
||||||
|
|
||||||
|
@ -68,25 +74,25 @@ main :: Effect Unit
|
||||||
main = do
|
main = do
|
||||||
log "🍝"
|
log "🍝"
|
||||||
|
|
||||||
case parse ishi2 "hi" of
|
log $ "parsing 'hi': " <> case parse ishi2 "hi" of
|
||||||
Just (Tuple x y) -> log ("parsing 'hi': " <> show x <> " " <> show y)
|
Just (Tuple x y) -> show x <> " " <> show y
|
||||||
Nothing -> log "coudn't parse two letters"
|
Nothing -> "coudn't parse two letters"
|
||||||
|
|
||||||
case parse ishi2 "no" of
|
log $ "parsing 'no': " <> case parse ishi2 "no" of
|
||||||
Just (Tuple x y) -> log ("parsing 'no': " <> show x <> " " <> show y)
|
Just (Tuple x y) -> show x <> " " <> show y
|
||||||
Nothing -> log "coudn't parse two letters"
|
Nothing -> "coudn't parse two letters"
|
||||||
|
|
||||||
case parse ishi2 "ho" of
|
log $ "parsing 'ho': " <> case parse ishi2 "ho" of
|
||||||
Just (Tuple x y) -> log ("parsing 'ho': " <> show x <> " " <> show y)
|
Just (Tuple x y) -> show x <> " " <> show y
|
||||||
Nothing -> log "coudn't parse two letters"
|
Nothing -> "coudn't parse two letters"
|
||||||
|
|
||||||
case parse ishi2 "ni" of
|
log $ "parsing 'ni': " <> case parse ishi2 "ni" of
|
||||||
Just (Tuple x y) -> log ("parsing 'ni': " <> show x <> " " <> show y)
|
Just (Tuple x y) -> show x <> " " <> show y
|
||||||
Nothing -> log "coudn't parse two letters"
|
Nothing -> "coudn't parse two letters"
|
||||||
|
|
||||||
case parse ishi2 "" of
|
log $ "parsing '': " <> case parse ishi2 "" of
|
||||||
Just (Tuple x y) -> log ("parsing '': " <> show x <> " " <> show y)
|
Just (Tuple x y) -> show x <> " " <> show y
|
||||||
Nothing -> log "coudn't parse two letters"
|
Nothing -> "coudn't parse two letters"
|
||||||
|
|
||||||
|
|
||||||
-- JUST WORKS
|
-- JUST WORKS
|
||||||
|
|
Loading…
Reference in New Issue