-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
canonicalize module names, generate unambiguous names in JS
Begging to address #826
- Loading branch information
1 parent
5943865
commit 31545d1
Showing
23 changed files
with
360 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ Library | |
AST.Helpers, | ||
AST.Literal, | ||
AST.Module, | ||
AST.Module.Name, | ||
AST.Pattern, | ||
AST.Type, | ||
AST.Variable, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module AST.Module.Name where | ||
|
||
import Control.Applicative ((<$>),(<*>)) | ||
import Data.Binary | ||
import qualified Data.List as List | ||
|
||
import qualified Elm.Package as Package | ||
|
||
|
||
type Raw = [String] -- must be non-empty | ||
|
||
|
||
data Canonical = Canonical | ||
{ _package :: Package.Name | ||
, _module :: Raw | ||
} | ||
deriving (Eq, Ord, Show) | ||
|
||
|
||
inCore :: Raw -> Canonical | ||
inCore raw = | ||
Canonical Package.coreName raw | ||
|
||
|
||
toString :: Raw -> String | ||
toString rawName = | ||
List.intercalate "." rawName | ||
|
||
|
||
canonicalToString :: Canonical -> String | ||
canonicalToString (Canonical _ rawName) = | ||
toString rawName | ||
|
||
|
||
isNative :: Raw -> Bool | ||
isNative name = | ||
case name of | ||
"Native" : _ -> | ||
True | ||
|
||
_ -> | ||
False | ||
|
||
|
||
instance Binary Canonical where | ||
put (Canonical home name) = | ||
put home >> put name | ||
|
||
get = | ||
Canonical <$> get <*> get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.