~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to src/full/Agda/Utils/ReadP.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane, d5cf60f
  • Date: 2015-05-20 13:08:33 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20150520130833-cdcmhagwsouna237
Tags: 2.4.2.2-2
[d5cf60f] Depend on ${shlibs:Depends}, to get libc (& maybe other) deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{-# LANGUAGE MagicHash, Rank2Types, DeriveFunctor #-}
 
1
{-# LANGUAGE DeriveFunctor #-}
 
2
{-# LANGUAGE MagicHash     #-}
 
3
{-# LANGUAGE Rank2Types    #-}
 
4
 
2
5
-----------------------------------------------------------------------------
3
6
-- |
4
7
 
190
193
-- | Run a parser on a list of tokens. Returns the list of complete matches.
191
194
parse :: ReadP t a -> [t] -> [a]
192
195
parse p ts = case complete p of
193
 
    R f -> map fst $ run (f return) ts
 
196
    R f -> map fst $ run (f return) ts
194
197
 
195
198
get :: ReadP t t
196
199
-- ^ Consumes and returns the next character.
426
429
 
427
430
parse' :: ReadP t a -> [t] -> Either a [t]
428
431
parse' p ts = case complete p of
429
 
    R f -> run' (f return) ts
 
432
    R f -> run' (f return) ts
430
433
 
431
434
-- ---------------------------------------------------------------------------
432
435
-- QuickCheck properties that hold for the combinators
489
492
>  prop_Gather s =
490
493
>    forAll readPWithoutReadS $ \p ->
491
494
>      readP_to_S (gather p) s =~
492
 
>        [ ((pre,x::Int),s')
493
 
>        | (x,s') <- readP_to_S p s
494
 
>        , let pre = take (length s - length s') s
495
 
>        ]
 
495
>        [ ((pre,x::Int),s')
 
496
>        | (x,s') <- readP_to_S p s
 
497
>        , let pre = take (length s - length s') s
 
498
>        ]
496
499
>
497
500
>  prop_String_Yes this s =
498
501
>    readP_to_S (string this) (this ++ s) =~