Instantly share code, notes, and snippets.

Embed
What would you like to do?

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.
@justinwoo

This comment has been minimized.

Copy link

justinwoo commented Jun 19, 2018

Suggesting type holes would also be good, since you can readily upgrade from purescript-dom to purescript-web-dom by using ?whatgoeshere and such over your existing uses of purescript-dom.

Also worth pointing out a lot of the work can be done by replacing Control.Monad.Effect with Effect and Eff e with Effect

@dstcruz

This comment has been minimized.

Copy link

dstcruz commented Jun 19, 2018

Should it not be Control.Monad.Eff to Effect, rather than Control.Monad.Effect to Effect?

@Rembane

This comment has been minimized.

Copy link
Owner

Rembane commented Jun 19, 2018

Thank you for comments, I've implemented your suggestions.

@dstcruz

This comment has been minimized.

Copy link

dstcruz commented Jun 19, 2018

Ok, found another one: import Control.Monad.Aff -> import Effect.Aff. Looks like the module just changed location.

@Rembane

This comment has been minimized.

Copy link
Owner

Rembane commented Jun 20, 2018

Thank you! Added!

@dstcruz

This comment has been minimized.

Copy link

dstcruz commented Jun 20, 2018

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

@dstcruz

This comment has been minimized.

Copy link

dstcruz commented Jun 20, 2018

Data.StrMap -> Foreign.Object

@Rembane

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

thomashoneyman commented Jun 30, 2018

Others that would be nice to add in:

Module moves:

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

Renames:

  • RowCons -> Cons
  • RowLacks -> Lacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment