Skip to content

Instantly share code, notes, and snippets.

@Rembane
Last active May 17, 2019 07:30
Show Gist options
  • Save Rembane/3ac53bdc9ea949e25c9c48b9eb55b3f2 to your computer and use it in GitHub Desktop.
Save Rembane/3ac53bdc9ea949e25c9c48b9eb55b3f2 to your computer and use it in GitHub Desktop.

How to upgrade to Purescript 0.12

Before we begin, the type search in Pursuit is a great way to search for the functions you need.

Reset your tooling by deleting the bower_components/, .psci_modules/, .pulp-cache/, .psc-package/ and output/ folders. Then run psc-package build --only-dependencies.

Import changes and effects

Using sed or your other favourite global replace tool to search and replace all occurences in the list below will get you a long way.

All effect rows have been removed. For instance Aff e a has become Aff a. With some more ninja regexes or a small parser you should be able to remove the effect rows.

  • Control.Monad.Eff with Effect
    • Eff e with Effect
  • Control.Monad.Aff with Effect.Aff
  • Data.StrMap with Foreign.Object
    • The type StrMap is renamed to Object.

Package changes

If you use psc-package, remove packages from the depends field in your psc-package.json file until psc-package build stops telling you it can't find packages. Then you well get a lot of compile time errors which you can take care of by using typed holes.

purescript-maps and purescript-sets are merged into the new package purescript-ordered-collections. StrMap is now called Object and moved into the new package purescript-foreign-object.

purescript-dom has become the purescript-web-* packages. Using typed holes will help you find the new functions.

Most other libraries have the relevant changes in their releases page on Github.

Missing functions

Where have all the functions gone? Programmers refactored them everyone.

liftEff'from Control.Monad.Aff has been moved into a quite elegant liftEffect instance function.

id has been renamed to identity.

Credits

  • Kritzcreek in the Purescript channel was the main source for this. I just changed the format.
  • @justinwoo for comments about typed holes.
  • @dstcruz for having really sharp eyes.
@dstcruz
Copy link

dstcruz commented Jun 20, 2018

Don't know if we care to add, but Aff and Canceler have similar changes.

@dstcruz
Copy link

dstcruz commented Jun 20, 2018

Data.StrMap -> Foreign.Object

@Rembane
Copy link
Author

Rembane commented Jun 21, 2018

@dstcruz: Aren't both Aff and Canceler in the new Effect.Aff? Where the change is covered by the renaming under the "Import changes and effects" header. Or have I misunderstood something?

The StrMap change has been added. Thank you!

@dstcruz
Copy link

dstcruz commented Jun 21, 2018

Yes, Aff and Canceler are indeed in Effect.Aff. Their type changed from Aff e a -> Aff a, and Canceler e -> Canceler. They are indeed related to the changes en Eff, so I don't know if you'd want to call them out separately or not.

@dstcruz
Copy link

dstcruz commented Jun 21, 2018

Sadly, just blindly doing a sed type of change doesn't deal with the forall eff part that you might have, but I think this is a good start. At least the compiler might start to help you here.

@Rembane
Copy link
Author

Rembane commented Jun 23, 2018

I added a paragraph where I explain that all effect rows has been removed.

Indeed. You need some serious regexes to clean out all the effect rows.

@thomashoneyman
Copy link

Others that would be nice to add in:

Module moves:

  • Data.Record -> Record
  • Data.Foreign -> Foreign

Renames:

  • RowCons -> Cons
  • RowLacks -> Lacks

@Beyarz
Copy link

Beyarz commented Feb 23, 2019

Ah sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment