2-- Module : Data.Text.Internal.Read
3-- Copyright : (c) 2014 Bryan O'Sullivan
6-- Maintainer : bos@serpentine.com
7-- Stability : experimental
10-- Common internal functiopns for reading textual data.
11module Data.Text.Internal.Read
21import Control.Applicative (Applicative(..))
22import Control.Arrow (first)
23import Control.Monad (ap)
26type IReader t a = t -> Either String (a,t)
28newtype IParser t a = P {
32instance Functor (IParser t) where
33 fmap f m = P $ fmap (first f) . runP m
35instance Applicative (IParser t) where
36 pure a = P $ \t -> Right (a,t)
40instance Monad (IParser t) where
42 m >>= k = P $ \t -> case runP m t of
44 Right (a,t') -> runP (k a) t'
46 fail msg = P $ \_ -> Left msg
48data T = T !Integer !Int
50perhaps :: a -> IParser t a -> IParser t a
51perhaps def m = P $ \t -> case runP m t of
52 Left _ -> Right (def,t)
55hexDigitToInt :: Char -> Int
57 | c >= '0' && c <= '9' = ord c - ord '0'
58 | c >= 'a' && c <= 'f' = ord c - (ord 'a' - 10)
59 | otherwise = ord c - (ord 'A' - 10)
61digitToInt :: Char -> Int
62digitToInt c = ord c - ord '0'
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list