1{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
12import Data.Int (Int64)
13import qualified Data.Text as S
14import qualified Data.Text.Lazy as L
15import qualified Data.Text.Read
18class PathPiece s where
19 fromPathPiece :: S.Text -> Maybe s
20 toPathPiece :: s -> S.Text
22instance PathPiece String where
23 fromPathPiece = Just . S.unpack
26instance PathPiece S.Text where
30instance PathPiece L.Text where
31 fromPathPiece = Just . L.fromChunks . return
32 toPathPiece = S.concat . L.toChunks
34instance PathPiece Integer where
36 case Data.Text.Read.signed Data.Text.Read.decimal s of
37 Right (i, _) -> Just i
39 toPathPiece = S.pack . show
41instance PathPiece Int where
43 case Data.Text.Read.signed Data.Text.Read.decimal s of
44 Right (i, _) -> Just i
46 toPathPiece = S.pack . show
48instance PathPiece Bool where
50 case reads $ S.unpack t of
53 toPathPiece = S.pack . show
55instance PathPiece Int64 where
57 case Data.Text.Read.signed Data.Text.Read.decimal s of
58 Right (i, _) -> Just i
60 toPathPiece = S.pack . show
62instance PathPiece Day where
64 case reads $ S.unpack t of
67 toPathPiece = S.pack . show
69class PathMultiPiece s where
70 fromPathMultiPiece :: [S.Text] -> Maybe s
71 toPathMultiPiece :: s -> [S.Text]
73instance PathMultiPiece [String] where
74 fromPathMultiPiece = Just . map S.unpack
75 toPathMultiPiece = map S.pack
77instance PathMultiPiece [S.Text] where
78 fromPathMultiPiece = Just
81instance PathMultiPiece [L.Text] where
82 fromPathMultiPiece = Just . map (L.fromChunks . return)
83 toPathMultiPiece = map $ S.concat . L.toChunks
85{-# DEPRECATED toSinglePiece "Use toPathPiece instead of toSinglePiece" #-}
86toSinglePiece :: PathPiece p => p -> S.Text
87toSinglePiece = toPathPiece
89{-# DEPRECATED fromSinglePiece "Use fromPathPiece instead of fromSinglePiece" #-}
90fromSinglePiece :: PathPiece p => S.Text -> Maybe p
91fromSinglePiece = fromPathPiece
93{-# DEPRECATED toMultiPiece "Use toPathMultiPiece instead of toMultiPiece" #-}
94toMultiPiece :: PathMultiPiece ps => ps -> [S.Text]
95toMultiPiece = toPathMultiPiece
97{-# DEPRECATED fromMultiPiece "Use fromPathMultiPiece instead of fromMultiPiece" #-}
98fromMultiPiece :: PathMultiPiece ps => [S.Text] -> Maybe ps
99fromMultiPiece = fromPathMultiPiece
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