Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into elm-serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
decioferreira committed Dec 11, 2024
1 parent caa10b9 commit 0ce32ec
Show file tree
Hide file tree
Showing 76 changed files with 1,385 additions and 1,450 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ This phase will foster a unified ecosystem that adapts to the needs of its users
Our ultimate goal is to create a language that inherits the best aspects of Elm while adapting and
growing to meet the needs of its users.

# Install

To install Guida as an npm package, run the following command:

```
npm install -g guida
```

You should now be able to run `guida --version`.

# Development

Start by installing [Node Version Manager](https://github.com/nvm-sh/nvm).
Expand Down Expand Up @@ -121,6 +131,32 @@ npm run test:elm-format-validate
npm run elm-format
```

# Publish new npm package version

Before publishing a new npm package version, make sure you are on the correct
branch, ie. in case of wanting to publish a 0.x version, you should have the
`v0.x` branch checked out.

To publish a new version, we should then run the following commands:

```
npm version <newversion>
npm publish
git push origin <currentbranch>
git push origin tag v<newversion>
```

As an example, these should have been the commands ran for publishing `v0.2.0-alpha`

```
npm version 0.2.0-alpha
npm publish
git push origin v0.x
git push origin tag v0.2.0-alpha
```

The `<newversion>` value relates to the `version` field value found on `package.json`.

# References

- Initial transpilation from Haskell to Elm done based on [Elm compiler v0.19.1](https://github.com/elm/compiler/releases/tag/0.19.1)
Expand Down
172 changes: 86 additions & 86 deletions src/Builder/Build.elm

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions src/Builder/Deps/Diff.elm
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ import Utils.Main as Utils


type PackageChanges
= PackageChanges (List ModuleName.Raw) (Dict ModuleName.Raw ModuleChanges) (List ModuleName.Raw)
= PackageChanges (List ModuleName.Raw) (Dict String ModuleName.Raw ModuleChanges) (List ModuleName.Raw)


type ModuleChanges
= ModuleChanges (Changes Name.Name Docs.Union) (Changes Name.Name Docs.Alias) (Changes Name.Name Docs.Value) (Changes Name.Name Docs.Binop)
= ModuleChanges (Changes String Name.Name Docs.Union) (Changes String Name.Name Docs.Alias) (Changes String Name.Name Docs.Value) (Changes String Name.Name Docs.Binop)


type Changes k v
= Changes (Dict k v) (Dict k ( v, v )) (Dict k v)
type Changes c k v
= Changes (Dict c k v) (Dict c k ( v, v )) (Dict c k v)


getChanges : (k -> k -> Order) -> (v -> v -> Bool) -> Dict k v -> Dict k v -> Changes k v
getChanges keyComparison isEquivalent old new =
getChanges : (k -> comparable) -> (k -> k -> Order) -> (v -> v -> Bool) -> Dict comparable k v -> Dict comparable k v -> Changes comparable k v
getChanges toComparable keyComparison isEquivalent old new =
let
overlap : Dict k ( v, v )
overlap : Dict comparable k ( v, v )
overlap =
Utils.mapIntersectionWith keyComparison Tuple.pair old new
Utils.mapIntersectionWith toComparable keyComparison Tuple.pair old new

changed : Dict k ( v, v )
changed : Dict comparable k ( v, v )
changed =
Dict.filter (\_ ( v1, v2 ) -> not (isEquivalent v1 v2)) overlap
in
Expand All @@ -65,26 +65,26 @@ getChanges keyComparison isEquivalent old new =
diff : Docs.Documentation -> Docs.Documentation -> PackageChanges
diff oldDocs newDocs =
let
filterOutPatches : Dict a ModuleChanges -> Dict a ModuleChanges
filterOutPatches : Dict comparable a ModuleChanges -> Dict comparable a ModuleChanges
filterOutPatches chngs =
Dict.filter (\_ chng -> moduleChangeMagnitude chng /= M.PATCH) chngs

(Changes added changed removed) =
getChanges compare (\_ _ -> False) oldDocs newDocs
getChanges identity compare (\_ _ -> False) oldDocs newDocs
in
PackageChanges
(Dict.keys added)
(Dict.keys compare added)
(filterOutPatches (Dict.map (\_ -> diffModule) changed))
(Dict.keys removed)
(Dict.keys compare removed)


diffModule : ( Docs.Module, Docs.Module ) -> ModuleChanges
diffModule ( Docs.Module _ _ u1 a1 v1 b1, Docs.Module _ _ u2 a2 v2 b2 ) =
ModuleChanges
(getChanges compare isEquivalentUnion u1 u2)
(getChanges compare isEquivalentAlias a1 a2)
(getChanges compare isEquivalentValue v1 v2)
(getChanges compare isEquivalentBinop b1 b2)
(getChanges identity compare isEquivalentUnion u1 u2)
(getChanges identity compare isEquivalentAlias a1 a2)
(getChanges identity compare isEquivalentValue v1 v2)
(getChanges identity compare isEquivalentBinop b1 b2)



Expand All @@ -109,7 +109,7 @@ isEquivalentUnion (Docs.Union oldComment oldVars oldCtors) (Docs.Union newCommen
in
(List.length oldCtors == List.length newCtors)
&& List.all identity (List.map2 (==) (List.map Tuple.first oldCtors) (List.map Tuple.first newCtors))
&& List.all identity (Dict.values (Utils.mapIntersectionWith compare equiv (Dict.fromList compare oldCtors) (Dict.fromList compare newCtors)))
&& List.all identity (Dict.values compare (Utils.mapIntersectionWith identity compare equiv (Dict.fromList identity oldCtors) (Dict.fromList identity newCtors)))


isEquivalentAlias : Docs.Alias -> Docs.Alias -> Bool
Expand Down Expand Up @@ -243,11 +243,11 @@ isEquivalentRenaming varPairs =
let
renamings : List ( Name.Name, List Name.Name )
renamings =
Dict.toList (List.foldr insert Dict.empty varPairs)
Dict.toList compare (List.foldr insert Dict.empty varPairs)

insert : ( Name.Name, Name.Name ) -> Dict Name.Name (List Name.Name) -> Dict Name.Name (List Name.Name)
insert : ( Name.Name, Name.Name ) -> Dict String Name.Name (List Name.Name) -> Dict String Name.Name (List Name.Name)
insert ( old, new ) dict =
Utils.mapInsertWith compare (++) old [ new ] dict
Utils.mapInsertWith identity (++) old [ new ] dict

verify : ( a, List b ) -> Maybe ( a, b )
verify ( old, news ) =
Expand All @@ -264,7 +264,7 @@ isEquivalentRenaming varPairs =

allUnique : List comparable -> Bool
allUnique list =
List.length list == EverySet.size (EverySet.fromList compare list)
List.length list == EverySet.size (EverySet.fromList identity list)
in
case Utils.maybeMapM verify renamings of
Nothing ->
Expand Down Expand Up @@ -364,7 +364,7 @@ toMagnitude (PackageChanges added changed removed) =

changeMags : List M.Magnitude
changeMags =
List.map moduleChangeMagnitude (Dict.values changed)
List.map moduleChangeMagnitude (Dict.values compare changed)
in
Utils.listMaximum M.compare (addMag :: removeMag :: changeMags)

Expand All @@ -379,7 +379,7 @@ moduleChangeMagnitude (ModuleChanges unions aliases values binops) =
]


changeMagnitude : Changes k v -> M.Magnitude
changeMagnitude : Changes comparable k v -> M.Magnitude
changeMagnitude (Changes added changed removed) =
if Dict.size removed > 0 || Dict.size changed > 0 then
M.MAJOR
Expand Down
22 changes: 11 additions & 11 deletions src/Builder/Deps/Registry.elm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import System.IO as IO exposing (IO)


type Registry
= Registry Int (Dict Pkg.Name KnownVersions)
= Registry Int (Dict ( String, String ) Pkg.Name KnownVersions)


type KnownVersions
Expand Down Expand Up @@ -68,7 +68,7 @@ fetch manager cache =
let
size : Int
size =
Dict.foldr (\_ -> addEntry) 0 versions
Dict.foldr Pkg.compareName (\_ -> addEntry) 0 versions

registry : Registry
registry =
Expand All @@ -87,7 +87,7 @@ addEntry (KnownVersions _ vs) count =
count + 1 + List.length vs


allPkgsDecoder : D.Decoder () (Dict Pkg.Name KnownVersions)
allPkgsDecoder : D.Decoder () (Dict ( String, String ) Pkg.Name KnownVersions)
allPkgsDecoder =
let
keyDecoder : D.KeyDecoder () Pkg.Name
Expand All @@ -107,7 +107,7 @@ allPkgsDecoder =
[] ->
D.failure ()
in
D.dict Pkg.compareName keyDecoder (D.bind toKnownVersions versionsDecoder)
D.dict identity keyDecoder (D.bind toKnownVersions versionsDecoder)



Expand All @@ -128,7 +128,7 @@ update manager cache ((Registry size packages) as oldRegistry) =
newSize =
size + List.length news

newPkgs : Dict Pkg.Name KnownVersions
newPkgs : Dict ( String, String ) Pkg.Name KnownVersions
newPkgs =
List.foldr addNew packages news

Expand All @@ -140,7 +140,7 @@ update manager cache ((Registry size packages) as oldRegistry) =
|> IO.fmap (\_ -> newRegistry)


addNew : ( Pkg.Name, V.Version ) -> Dict Pkg.Name KnownVersions -> Dict Pkg.Name KnownVersions
addNew : ( Pkg.Name, V.Version ) -> Dict ( String, String ) Pkg.Name KnownVersions -> Dict ( String, String ) Pkg.Name KnownVersions
addNew ( name, version ) versions =
let
add : Maybe KnownVersions -> KnownVersions
Expand All @@ -152,7 +152,7 @@ addNew ( name, version ) versions =
Nothing ->
KnownVersions version []
in
Dict.update Pkg.compareName name (Just << add) versions
Dict.update identity name (Just << add) versions



Expand Down Expand Up @@ -204,17 +204,17 @@ latest manager cache =

getVersions : Pkg.Name -> Registry -> Maybe KnownVersions
getVersions name (Registry _ versions) =
Dict.get name versions
Dict.get identity name versions


getVersions_ : Pkg.Name -> Registry -> Result (List Pkg.Name) KnownVersions
getVersions_ name (Registry _ versions) =
case Dict.get name versions of
case Dict.get identity name versions of
Just kvs ->
Ok kvs

Nothing ->
Err (Pkg.nearbyNames name (Dict.keys versions))
Err (Pkg.nearbyNames name (Dict.keys compare versions))



Expand Down Expand Up @@ -248,5 +248,5 @@ registryCodec =
(\registryCodecEncoder (Registry size packages) ->
registryCodecEncoder size packages
)
|> Serialize.variant2 Registry Serialize.int (S.assocListDict Pkg.compareName Pkg.nameCodec knownVersionsCodec)
|> Serialize.variant2 Registry Serialize.int (S.assocListDict identity Pkg.compareName Pkg.nameCodec knownVersionsCodec)
|> Serialize.finishCustomType
Loading

0 comments on commit 0ce32ec

Please sign in to comment.