@@ -29,6 +29,7 @@ import Data.Binary (Binary, get, getWord8, put, putWord8)
2929import qualified Data.Char as Char
3030import Data.Function (on)
3131import qualified Data.List as List
32+import qualified Data.Name as Name
3233import qualified Data.Map as Map
3334import Data.Monoid ((<>))
3435import qualified Data.Text as Text
@@ -40,7 +41,6 @@ import Data.Text (Text)
4041import Data.Word (Word16)
4142import System.FilePath ((</>))
4243
43−import qualified Elm.Name as N
4444import qualified Json.Decode.Internals as Decode
4545import qualified Json.Encode as Encode
4646
@@ -51,8 +51,8 @@ import qualified Json.Encode as Encode
5151
5252data Name =
5353 Name
54− { _author :: !Text
55− , _project :: !Text
54+ { _author :: !Name.Name
55+ , _project :: !Name.Name
5656 }
5757 deriving (Eq, Ord)
5858
@@ -75,30 +75,30 @@ isKernel (Name author _) =
7575
7676
7777toString :: Name -> String
78−toString name =
79− Text.unpack (toText name)
78+toString (Name author project) =
79+ Name.toString author <> "/" <> Name.toString project
8080
8181
8282toText :: Name -> Text
83−toText (Name author project) =
84− author <> "/" <> project
83+toText name =
84+ Text.pack (toString name)
8585
8686
8787toUrl :: Name -> String
8888toUrl (Name author project) =
89− Text.unpack author ++ "/" ++ Text.unpack project
89+ Name.toString author ++ "/" ++ Name.toString project
9090
9191
9292toFilePath :: Name -> FilePath
9393toFilePath (Name author project) =
94− Text.unpack author </> Text.unpack project
94+ Name.toString author </> Name.toString project
9595
9696
9797fromText :: Text -> Either (String, [String]) Name
9898fromText text =
9999 case Text.splitOn "/" text of
100100 [ author, project ] | not (Text.null author || Text.null project) ->
101− Name author <$> validateProjectName project
101+ Name (Name.fromString (Text.unpack author)) <$> validateProjectName project
102102
103103 _ ->
104104 Left
@@ -107,7 +107,7 @@ fromText text =
107107 )
108108
109109
110−validateProjectName :: Text -> Either (String, [String]) Text
110+validateProjectName :: Text -> Either (String, [String]) Name.Name
111111validateProjectName text =
112112 if Text.isInfixOf "--" text then
113113 Left $ thisCannot "have two dashes in a row" text (Text.replace "--" "-" text)
@@ -131,7 +131,7 @@ validateProjectName text =
131131 Left $ thisCannot "end with a dash" text (Text.dropEnd 1 text)
132132
133133 else
134− Right text
134+ Right (Name.fromString (Text.unpack text))
135135
136136
137137thisCannot :: String -> Text -> Text -> (String, [String])
@@ -240,7 +240,7 @@ linearAlgebra =
240240-- PACKAGE SUGGESTIONS
241241
242242
243−suggestions :: Map.Map N.Name Name
243+suggestions :: Map.Map Name.Name Name
244244suggestions =
245245 Map.fromList
246246 [ ("Browser", browser)