@@ -29,6 +29,7 @@ import Data.Binary (Binary, get, getWord8, put, putWord8)
29import qualified Data.Char as Char
29import qualified Data.Char as Char
30import Data.Function (on)
30import Data.Function (on)
31import qualified Data.List as List
31import qualified Data.List as List
32+import qualified Data.Name as Name
32import qualified Data.Map as Map
33import qualified Data.Map as Map
33import Data.Monoid ((<>))
34import Data.Monoid ((<>))
34import qualified Data.Text as Text
35import qualified Data.Text as Text
@@ -40,7 +41,6 @@ import Data.Text (Text)
40import Data.Word (Word16)
41import Data.Word (Word16)
41import System.FilePath ((</>))
42import System.FilePath ((</>))
43−import qualified Elm.Name as N
44import qualified Json.Decode.Internals as Decode
44import qualified Json.Decode.Internals as Decode
45import qualified Json.Encode as Encode
45import qualified Json.Encode as Encode
@@ -51,8 +51,8 @@ import qualified Json.Encode as Encode
52data Name =
52data Name =
54− { _author :: !Text
54+ { _author :: !Name.Name
55− , _project :: !Text
55+ , _project :: !Name.Name
57 deriving (Eq, Ord)
57 deriving (Eq, Ord)
@@ -75,30 +75,30 @@ isKernel (Name author _) =
77toString :: Name -> String
77toString :: Name -> String
78−toString name =
78+toString (Name author project) =
79− Text.unpack (toText name)
79+ Name.toString author <> "/" <> Name.toString project
82toText :: Name -> Text
82toText :: Name -> Text
83−toText (Name author project) =
83+toText name =
84− author <> "/" <> project
84+ Text.pack (toString name)
87toUrl :: Name -> String
87toUrl :: Name -> String
88toUrl (Name author project) =
88toUrl (Name author project) =
89− Text.unpack author ++ "/" ++ Text.unpack project
89+ Name.toString author ++ "/" ++ Name.toString project
92toFilePath :: Name -> FilePath
92toFilePath :: Name -> FilePath
93toFilePath (Name author project) =
93toFilePath (Name author project) =
94− Text.unpack author </> Text.unpack project
94+ Name.toString author </> Name.toString project
97fromText :: Text -> Either (String, [String]) Name
97fromText :: Text -> Either (String, [String]) Name
98fromText text =
98fromText text =
99 case Text.splitOn "/" text of
99 case Text.splitOn "/" text of
100 [ author, project ] | not (Text.null author || Text.null project) ->
100 [ author, project ] | not (Text.null author || Text.null project) ->
101− Name author <$> validateProjectName project
101+ Name (Name.fromString (Text.unpack author)) <$> validateProjectName project
@@ -107,7 +107,7 @@ fromText text =
110−validateProjectName :: Text -> Either (String, [String]) Text
110+validateProjectName :: Text -> Either (String, [String]) Name.Name
111validateProjectName text =
111validateProjectName text =
112 if Text.isInfixOf "--" text then
112 if Text.isInfixOf "--" text then
113 Left $ thisCannot "have two dashes in a row" text (Text.replace "--" "-" text)
113 Left $ thisCannot "have two dashes in a row" text (Text.replace "--" "-" text)
@@ -131,7 +131,7 @@ validateProjectName text =
131 Left $ thisCannot "end with a dash" text (Text.dropEnd 1 text)
131 Left $ thisCannot "end with a dash" text (Text.dropEnd 1 text)
134− Right text
134+ Right (Name.fromString (Text.unpack text))
137thisCannot :: String -> Text -> Text -> (String, [String])
137thisCannot :: String -> Text -> Text -> (String, [String])
@@ -240,7 +240,7 @@ linearAlgebra =
240-- PACKAGE SUGGESTIONS
240-- PACKAGE SUGGESTIONS
243−suggestions :: Map.Map N.Name Name
243+suggestions :: Map.Map Name.Name Name
244suggestions =
244suggestions =
245 Map.fromList
245 Map.fromList
246 [ ("Browser", browser)
246 [ ("Browser", browser)