]> Git — Sourcephile - haskell/symantic-parser.git/blob - parsers/Parsers/Utils/Handrolled.hs
add benchmarks
[haskell/symantic-parser.git] / parsers / Parsers / Utils / Handrolled.hs
1 {-# LANGUAGE TypeFamilies #-}
2 module Parsers.Utils.Handrolled where
3
4 import Control.Monad (Monad(..), fail)
5 import Data.Bool (Bool)
6 import Data.Char (Char)
7 import Data.Maybe (Maybe(..))
8 import Data.Word (Word8)
9 import qualified Data.ByteString as BS
10 import qualified Data.Text as T
11
12 -- * Class 'Inputable'
13 class Inputable inp where
14 type Token inp
15 null :: inp -> Bool
16 empty :: inp
17 uncons :: inp -> Maybe (Token inp, inp)
18 instance Inputable T.Text where
19 type Token T.Text = Char
20 null = T.null
21 empty = T.empty
22 uncons = T.uncons
23 instance Inputable BS.ByteString where
24 type Token BS.ByteString = Word8
25 null = BS.null
26 empty = BS.empty
27 uncons = BS.uncons