shortcut-links 0.4.1.0 → 0.4.2.0
raw patch · 4 files changed
+40/−14 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- ShortcutLinks: [Failure] :: String -> Result a
- ShortcutLinks: [Success] :: a -> Result a
- ShortcutLinks: [Warning] :: [String] -> a -> Result a
- ShortcutLinks.All: [Failure] :: String -> Result a
- ShortcutLinks.All: [Success] :: a -> Result a
- ShortcutLinks.All: [Warning] :: [String] -> a -> Result a
- ShortcutLinks.All: instance Applicative Result
- ShortcutLinks.All: instance Functor Result
- ShortcutLinks.All: instance Monad Result
- ShortcutLinks.All: instance Show a => Show (Result a)
- ShortcutLinks.Utils: instance (FormatArg a, FormatType r) => FormatType (a -> r)
- ShortcutLinks.Utils: instance FormatArg Int
- ShortcutLinks.Utils: instance FormatArg Integer
- ShortcutLinks.Utils: instance FormatArg String
- ShortcutLinks.Utils: instance FormatArg Text
- ShortcutLinks.Utils: instance FormatType String
- ShortcutLinks.Utils: instance FormatType Text
+ ShortcutLinks: Failure :: String -> Result a
+ ShortcutLinks: Success :: a -> Result a
+ ShortcutLinks: Warning :: [String] -> a -> Result a
+ ShortcutLinks: useShortcutFrom :: [([Text], Shortcut)] -> Text -> Maybe Text -> Text -> Result Text
+ ShortcutLinks.All: Failure :: String -> Result a
+ ShortcutLinks.All: Success :: a -> Result a
+ ShortcutLinks.All: Warning :: [String] -> a -> Result a
+ ShortcutLinks.All: instance GHC.Base.Applicative ShortcutLinks.All.Result
+ ShortcutLinks.All: instance GHC.Base.Functor ShortcutLinks.All.Result
+ ShortcutLinks.All: instance GHC.Base.Monad ShortcutLinks.All.Result
+ ShortcutLinks.All: instance GHC.Show.Show a => GHC.Show.Show (ShortcutLinks.All.Result a)
+ ShortcutLinks.Utils: instance (ShortcutLinks.Utils.FormatArg a, ShortcutLinks.Utils.FormatType r) => ShortcutLinks.Utils.FormatType (a -> r)
+ ShortcutLinks.Utils: instance ShortcutLinks.Utils.FormatArg Data.Text.Internal.Text
+ ShortcutLinks.Utils: instance ShortcutLinks.Utils.FormatArg GHC.Base.String
+ ShortcutLinks.Utils: instance ShortcutLinks.Utils.FormatArg GHC.Integer.Type.Integer
+ ShortcutLinks.Utils: instance ShortcutLinks.Utils.FormatArg GHC.Types.Int
+ ShortcutLinks.Utils: instance ShortcutLinks.Utils.FormatType Data.Text.Internal.Text
+ ShortcutLinks.Utils: instance ShortcutLinks.Utils.FormatType GHC.Base.String
Files
- CHANGELOG.md +5/−0
- shortcut-links.cabal +1/−1
- src/ShortcutLinks.hs +22/−7
- src/ShortcutLinks/All.hs +12/−6
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.4.2.0++* Added `useShortcutFrom`.+* `@` is now allowed in Github/Gitlab/Bitbucket nicks.+ # 0.4.1.0 * Exported `useShortcut` (gee).
shortcut-links.cabal view
@@ -1,5 +1,5 @@ name: shortcut-links-version: 0.4.1.0+version: 0.4.2.0 synopsis: Link shortcuts for use in text markup description: This package is a database of link shortcuts. A Markdown example:
src/ShortcutLinks.hs view
@@ -8,6 +8,7 @@ Shortcut, allShortcuts, useShortcut,+ useShortcutFrom, ) where @@ -22,15 +23,29 @@ -- | Use a shortcut from 'allShortcuts'. ----- This is the main function you should use. It does the lookup and so on.+-- This is the main function you should use. useShortcut- :: Text -- ^ Shortcut name- -> Maybe Text -- ^ Option- -> Text -- ^ Link text- -> Result Text -- ^ Resulting URL-useShortcut name option link =+ :: Text -- ^ Shortcut name+ -> Maybe Text -- ^ Option+ -> Text -- ^ Link text+ -> Result Text -- ^ Resulting URL+useShortcut = useShortcutFrom allShortcuts++-- | Use a shortcut from a list.+--+-- For instance, if you want to add @hk@ as a synonym for @hackage@, you'd+-- write:+--+-- >>> useShortcutFrom ((["hk"], hackage) : allShortcuts)+useShortcutFrom+ :: [([Text], Shortcut)]+ -> Text -- ^ Shortcut name+ -> Maybe Text -- ^ Option+ -> Text -- ^ Link text+ -> Result Text -- ^ Resulting URL+useShortcutFrom shortcuts name option link = let givenShortcut (names,_) = name `elem` names- in case filter givenShortcut allShortcuts of+ in case filter givenShortcut shortcuts of [] -> fail (format "there's no shortcut named '{}'" name) [sh] -> (snd sh) option link _ -> fail (format "there's more than one shortcut named '{}'" name)
src/ShortcutLinks/All.hs view
@@ -573,8 +573,10 @@ -} github :: Shortcut github mbOwner q = case mbOwner of- Nothing -> return $ format "https://github.com/{}" q- Just owner -> return $ format "https://github.com/{}/{}" owner q+ Nothing -> return $ format "https://github.com/{}" (stripAt q)+ Just owner -> return $ format "https://github.com/{}/{}" (stripAt owner) q+ where+ stripAt x = if T.head x == '@' then T.tail x else x {- | <https://bitbucket.org Bitbucket> (shortcut: “bitbucket”) @@ -601,8 +603,10 @@ -} bitbucket :: Shortcut bitbucket mbOwner q = case mbOwner of- Nothing -> return $ format "https://bitbucket.org/{}" q- Just owner -> return $ format "https://bitbucket.org/{}/{}" owner q+ Nothing -> return $ format "https://bitbucket.org/{}" (stripAt q)+ Just owner -> return $ format "https://bitbucket.org/{}/{}" (stripAt owner) q+ where+ stripAt x = if T.head x == '@' then T.tail x else x {- | <https://gitlab.com Gitlab> (shortcut: “gitlab”) @@ -629,8 +633,10 @@ -} gitlab :: Shortcut gitlab mbOwner q = case mbOwner of- Nothing -> return $ format "https://gitlab.com/{}" q- Just owner -> return $ format "https://gitlab.com/{}/{}" owner q+ Nothing -> return $ format "https://gitlab.com/{}" (stripAt q)+ Just owner -> return $ format "https://gitlab.com/{}/{}" (stripAt owner) q+ where+ stripAt x = if T.head x == '@' then T.tail x else x {- | __Android__ – <https://play.google.com Google Play> (formerly Play Market) (shortcut: “gplay” or “googleplay”)