{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.SPDX.LicenseReference (
LicenseRef,
licenseRef,
licenseDocumentRef,
mkLicenseRef,
mkLicenseRef',
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.Generic (isAsciiAlphaNum)
import Distribution.Pretty
import Distribution.Parsec
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
data LicenseRef = LicenseRef
{ LicenseRef -> Maybe String
_lrDocument :: !(Maybe String)
, LicenseRef -> String
_lrLicense :: !String
}
deriving (Int -> LicenseRef -> ShowS
[LicenseRef] -> ShowS
LicenseRef -> String
(Int -> LicenseRef -> ShowS)
-> (LicenseRef -> String)
-> ([LicenseRef] -> ShowS)
-> Show LicenseRef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LicenseRef] -> ShowS
$cshowList :: [LicenseRef] -> ShowS
show :: LicenseRef -> String
$cshow :: LicenseRef -> String
showsPrec :: Int -> LicenseRef -> ShowS
$cshowsPrec :: Int -> LicenseRef -> ShowS
External instance of the constraint type Show Char
External instance of the constraint type Show Char
External instance of the constraint type forall a. Show a => Show [a]
External instance of the constraint type forall a. Show a => Show [a]
External instance of the constraint type Show Char
External instance of the constraint type forall a. Show a => Show (Maybe a)
External instance of the constraint type Ord Int
Show, ReadPrec [LicenseRef]
ReadPrec LicenseRef
Int -> ReadS LicenseRef
ReadS [LicenseRef]
(Int -> ReadS LicenseRef)
-> ReadS [LicenseRef]
-> ReadPrec LicenseRef
-> ReadPrec [LicenseRef]
-> Read LicenseRef
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LicenseRef]
$creadListPrec :: ReadPrec [LicenseRef]
readPrec :: ReadPrec LicenseRef
$creadPrec :: ReadPrec LicenseRef
readList :: ReadS [LicenseRef]
$creadList :: ReadS [LicenseRef]
readsPrec :: Int -> ReadS LicenseRef
$creadsPrec :: Int -> ReadS LicenseRef
External instance of the constraint type Read Char
External instance of the constraint type Read Char
External instance of the constraint type forall a. Read a => Read [a]
External instance of the constraint type forall a. Read a => Read [a]
External instance of the constraint type Read Char
External instance of the constraint type forall a. Read a => Read (Maybe a)
External instance of the constraint type Monad ReadPrec
External instance of the constraint type Monad ReadPrec
Instance of class: Read of the constraint type Read LicenseRef
Read, LicenseRef -> LicenseRef -> Bool
(LicenseRef -> LicenseRef -> Bool)
-> (LicenseRef -> LicenseRef -> Bool) -> Eq LicenseRef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LicenseRef -> LicenseRef -> Bool
$c/= :: LicenseRef -> LicenseRef -> Bool
== :: LicenseRef -> LicenseRef -> Bool
$c== :: LicenseRef -> LicenseRef -> Bool
External instance of the constraint type Eq Char
External instance of the constraint type Eq Char
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq Char
External instance of the constraint type forall a. Eq a => Eq (Maybe a)
Eq, Eq LicenseRef
Eq LicenseRef
-> (LicenseRef -> LicenseRef -> Ordering)
-> (LicenseRef -> LicenseRef -> Bool)
-> (LicenseRef -> LicenseRef -> Bool)
-> (LicenseRef -> LicenseRef -> Bool)
-> (LicenseRef -> LicenseRef -> Bool)
-> (LicenseRef -> LicenseRef -> LicenseRef)
-> (LicenseRef -> LicenseRef -> LicenseRef)
-> Ord LicenseRef
LicenseRef -> LicenseRef -> Bool
LicenseRef -> LicenseRef -> Ordering
LicenseRef -> LicenseRef -> LicenseRef
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LicenseRef -> LicenseRef -> LicenseRef
$cmin :: LicenseRef -> LicenseRef -> LicenseRef
max :: LicenseRef -> LicenseRef -> LicenseRef
$cmax :: LicenseRef -> LicenseRef -> LicenseRef
>= :: LicenseRef -> LicenseRef -> Bool
$c>= :: LicenseRef -> LicenseRef -> Bool
> :: LicenseRef -> LicenseRef -> Bool
$c> :: LicenseRef -> LicenseRef -> Bool
<= :: LicenseRef -> LicenseRef -> Bool
$c<= :: LicenseRef -> LicenseRef -> Bool
< :: LicenseRef -> LicenseRef -> Bool
$c< :: LicenseRef -> LicenseRef -> Bool
compare :: LicenseRef -> LicenseRef -> Ordering
$ccompare :: LicenseRef -> LicenseRef -> Ordering
External instance of the constraint type Ord Char
External instance of the constraint type Ord Char
External instance of the constraint type Ord Char
External instance of the constraint type forall a. Ord a => Ord [a]
External instance of the constraint type forall a. Ord a => Ord [a]
External instance of the constraint type Ord Char
External instance of the constraint type forall a. Ord a => Ord [a]
External instance of the constraint type Ord Char
External instance of the constraint type forall a. Ord a => Ord (Maybe a)
Instance of class: Eq of the constraint type Eq LicenseRef
Instance of class: Ord of the constraint type Ord LicenseRef
Instance of class: Eq of the constraint type Eq LicenseRef
Ord, Typeable, Typeable LicenseRef
DataType
Constr
Typeable LicenseRef
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LicenseRef -> c LicenseRef)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LicenseRef)
-> (LicenseRef -> Constr)
-> (LicenseRef -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LicenseRef))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c LicenseRef))
-> ((forall b. Data b => b -> b) -> LicenseRef -> LicenseRef)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r)
-> (forall u. (forall d. Data d => d -> u) -> LicenseRef -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> LicenseRef -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef)
-> Data LicenseRef
LicenseRef -> DataType
LicenseRef -> Constr
(forall b. Data b => b -> b) -> LicenseRef -> LicenseRef
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LicenseRef -> c LicenseRef
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LicenseRef
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> LicenseRef -> u
forall u. (forall d. Data d => d -> u) -> LicenseRef -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LicenseRef
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LicenseRef -> c LicenseRef
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LicenseRef)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LicenseRef)
$cLicenseRef :: Constr
$tLicenseRef :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
gmapMp :: (forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
gmapM :: (forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LicenseRef -> m LicenseRef
gmapQi :: Int -> (forall d. Data d => d -> u) -> LicenseRef -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> LicenseRef -> u
gmapQ :: (forall d. Data d => d -> u) -> LicenseRef -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> LicenseRef -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LicenseRef -> r
gmapT :: (forall b. Data b => b -> b) -> LicenseRef -> LicenseRef
$cgmapT :: (forall b. Data b => b -> b) -> LicenseRef -> LicenseRef
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LicenseRef)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LicenseRef)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c LicenseRef)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LicenseRef)
dataTypeOf :: LicenseRef -> DataType
$cdataTypeOf :: LicenseRef -> DataType
toConstr :: LicenseRef -> Constr
$ctoConstr :: LicenseRef -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LicenseRef
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LicenseRef
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LicenseRef -> c LicenseRef
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LicenseRef -> c LicenseRef
External instance of the constraint type Data Char
External instance of the constraint type Data Char
External instance of the constraint type forall a. Data a => Data [a]
External instance of the constraint type Data Char
External instance of the constraint type forall a. Data a => Data (Maybe a)
External instance of the constraint type Data Char
External instance of the constraint type forall a. Data a => Data [a]
External instance of the constraint type forall a. Data a => Data [a]
External instance of the constraint type Data Char
Data, (forall x. LicenseRef -> Rep LicenseRef x)
-> (forall x. Rep LicenseRef x -> LicenseRef) -> Generic LicenseRef
forall x. Rep LicenseRef x -> LicenseRef
forall x. LicenseRef -> Rep LicenseRef x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LicenseRef x -> LicenseRef
$cfrom :: forall x. LicenseRef -> Rep LicenseRef x
Generic)
licenseRef :: LicenseRef -> String
licenseRef :: LicenseRef -> String
licenseRef = LicenseRef -> String
_lrLicense
licenseDocumentRef :: LicenseRef -> Maybe String
licenseDocumentRef :: LicenseRef -> Maybe String
licenseDocumentRef = LicenseRef -> Maybe String
_lrDocument
instance Binary LicenseRef
instance Structured LicenseRef
instance NFData LicenseRef where
rnf :: LicenseRef -> ()
rnf (LicenseRef Maybe String
d String
l) = Maybe String -> ()
forall a. NFData a => a -> ()
External instance of the constraint type forall a. NFData a => NFData (Maybe a)
External instance of the constraint type forall a. NFData a => NFData [a]
External instance of the constraint type NFData Char
rnf Maybe String
d () -> () -> ()
`seq` String -> ()
forall a. NFData a => a -> ()
External instance of the constraint type forall a. NFData a => NFData [a]
External instance of the constraint type NFData Char
rnf String
l
instance Pretty LicenseRef where
pretty :: LicenseRef -> Doc
pretty (LicenseRef Maybe String
Nothing String
l) = String -> Doc
Disp.text String
"LicenseRef-" Doc -> Doc -> Doc
<<>> String -> Doc
Disp.text String
l
pretty (LicenseRef (Just String
d) String
l) =
String -> Doc
Disp.text String
"DocumentRef-" Doc -> Doc -> Doc
<<>> String -> Doc
Disp.text String
d Doc -> Doc -> Doc
<<>> Char -> Doc
Disp.char Char
':' Doc -> Doc -> Doc
<<>> String -> Doc
Disp.text String
"LicenseRef-" Doc -> Doc -> Doc
<<>> String -> Doc
Disp.text String
l
instance Parsec LicenseRef where
parsec :: m LicenseRef
parsec = m LicenseRef
name m LicenseRef -> m LicenseRef -> m LicenseRef
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
External instance of the constraint type forall (m :: * -> *). Parsing m => Alternative m
External instance of the constraint type forall (m :: * -> *). CharParsing m => Parsing m
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
<|> m LicenseRef
doc
where
name :: m LicenseRef
name = do
String
_ <- String -> m String
forall (m :: * -> *). CharParsing m => String -> m String
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.string String
"LicenseRef-"
String
n <- m Char -> m String
forall (f :: * -> *) a. Alternative f => f a -> f [a]
External instance of the constraint type forall (m :: * -> *). Parsing m => Alternative m
External instance of the constraint type forall (m :: * -> *). CharParsing m => Parsing m
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
some (m Char -> m String) -> m Char -> m String
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> m Char
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.satisfy ((Char -> Bool) -> m Char) -> (Char -> Bool) -> m Char
forall a b. (a -> b) -> a -> b
$ \Char
c -> Char -> Bool
isAsciiAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'-' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'.'
LicenseRef -> m LicenseRef
forall (f :: * -> *) a. Applicative f => a -> f a
External instance of the constraint type forall (f :: * -> *). Alternative f => Applicative f
External instance of the constraint type forall (m :: * -> *). Parsing m => Alternative m
External instance of the constraint type forall (m :: * -> *). CharParsing m => Parsing m
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
pure (Maybe String -> String -> LicenseRef
LicenseRef Maybe String
forall a. Maybe a
Nothing String
n)
doc :: m LicenseRef
doc = do
String
_ <- String -> m String
forall (m :: * -> *). CharParsing m => String -> m String
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.string String
"DocumentRef-"
String
d <- m Char -> m String
forall (f :: * -> *) a. Alternative f => f a -> f [a]
External instance of the constraint type forall (m :: * -> *). Parsing m => Alternative m
External instance of the constraint type forall (m :: * -> *). CharParsing m => Parsing m
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
some (m Char -> m String) -> m Char -> m String
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> m Char
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.satisfy ((Char -> Bool) -> m Char) -> (Char -> Bool) -> m Char
forall a b. (a -> b) -> a -> b
$ \Char
c -> Char -> Bool
isAsciiAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'-' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'.'
Char
_ <- Char -> m Char
forall (m :: * -> *). CharParsing m => Char -> m Char
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.char Char
':'
String
_ <- String -> m String
forall (m :: * -> *). CharParsing m => String -> m String
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.string String
"LicenseRef-"
String
n <- m Char -> m String
forall (f :: * -> *) a. Alternative f => f a -> f [a]
External instance of the constraint type forall (m :: * -> *). Parsing m => Alternative m
External instance of the constraint type forall (m :: * -> *). CharParsing m => Parsing m
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
some (m Char -> m String) -> m Char -> m String
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> m Char
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
P.satisfy ((Char -> Bool) -> m Char) -> (Char -> Bool) -> m Char
forall a b. (a -> b) -> a -> b
$ \Char
c -> Char -> Bool
isAsciiAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'-' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'.'
LicenseRef -> m LicenseRef
forall (f :: * -> *) a. Applicative f => a -> f a
External instance of the constraint type forall (f :: * -> *). Alternative f => Applicative f
External instance of the constraint type forall (m :: * -> *). Parsing m => Alternative m
External instance of the constraint type forall (m :: * -> *). CharParsing m => Parsing m
External instance of the constraint type forall (m :: * -> *). CabalParsing m => CharParsing m
Evidence bound by a type signature of the constraint type CabalParsing m
pure (Maybe String -> String -> LicenseRef
LicenseRef (String -> Maybe String
forall a. a -> Maybe a
Just String
d) String
n)
mkLicenseRef :: Maybe String -> String -> Maybe LicenseRef
mkLicenseRef :: Maybe String -> String -> Maybe LicenseRef
mkLicenseRef Maybe String
d String
l = do
Maybe String
d' <- (String -> Maybe String) -> Maybe String -> Maybe (Maybe String)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
External instance of the constraint type Applicative Maybe
External instance of the constraint type Traversable Maybe
traverse String -> Maybe String
forall {t :: * -> *}. Foldable t => t Char -> Maybe (t Char)
External instance of the constraint type Foldable []
checkIdString Maybe String
d
String
l' <- String -> Maybe String
forall {t :: * -> *}. Foldable t => t Char -> Maybe (t Char)
External instance of the constraint type Foldable []
checkIdString String
l
LicenseRef -> Maybe LicenseRef
forall (f :: * -> *) a. Applicative f => a -> f a
External instance of the constraint type Applicative Maybe
pure (Maybe String -> String -> LicenseRef
LicenseRef Maybe String
d' String
l')
where
checkIdString :: t Char -> Maybe (t Char)
checkIdString t Char
s
| (Char -> Bool) -> t Char -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Evidence bound by a type signature of the constraint type Foldable t
all (\Char
c -> Char -> Bool
isAsciiAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'-' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'.') t Char
s = t Char -> Maybe (t Char)
forall a. a -> Maybe a
Just t Char
s
| Bool
otherwise = Maybe (t Char)
forall a. Maybe a
Nothing
mkLicenseRef' :: Maybe String -> String -> LicenseRef
mkLicenseRef' :: Maybe String -> String -> LicenseRef
mkLicenseRef' Maybe String
d String
l = Maybe String -> String -> LicenseRef
LicenseRef (ShowS -> Maybe String -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
fmap ShowS
f Maybe String
d) (ShowS
f String
l)
where
f :: ShowS
f = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
g
g :: Char -> Char
g Char
c | Char -> Bool
isAsciiAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'-' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Char
== Char
'.' = Char
c
| Bool
otherwise = Char
'-'