The Haskell Refactorer
See all
Members (77)

Stream

AlanKim Zimmerman
owner

Discussion  - 
 
HaRe 0.7.1.3 is now on hackage. It has mainly been a stabilisation process, with focus on renaming of real world source code.
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Version 0.7.1.0 is out

This one adresses the issue of refactoring multiple main modules : executables, tests, benchmarks, etc.
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
I have finally managed to get a new version out, 0.7.0.8.

The major change is a complete rework of the token output stage, to use the same data structure as the diagrams package, namely dual-tree.

This makes the tricky process of ensuring that layout is preserved as changes are made manageable. This is done in a two phase process, the first is to process the ParsedSource which is still (mostly) in linear order and generate a token tree which explicitly represents the subtrees that need to maintain vertical order (do/where/let etc). This is manipulated as before, keeping itin sync with the changing RenamedSource AST.

The second phase generates final output by constructing a DualTree from the TokenTree which bubbles up the source lines to be output, maintaining layout constraints on the way.

In future the Token Tree and Dual Tree should be merged, this was just the first step to make sure it actually works, discarding the Token Tree.

I will be able to deal with issues for the next day or so, but will then be away for a month on my summer holiday, in Australia
1
Add a comment...
 
Simon Peyton Jones kicks off the Scala eXchange with a keynote on Haskell, Lenses and Types

The Scala eXchange 2013 kicked off with a challenging keynote by   on #Lenses and #Types. Simon was joined by 400+ members of Europe's Scala community, gathering for 2 intensive days of learning and sharing skills on #Functional Programming, Reactive Programming and Scala! You can watch a SkillsCast (film/code/slides) of Simon's keynote here http://skillsmatter.com/podcast/home/simon-peyton-jones/wd-8776

The rest of the Scala eXchange featured just talks on Scala, but as there are many common challenges faced by and ideas within both the Scala and Haskell community, I thought to provide you with the links and overview of the rest of the conference too:

Simon's keynote, we split into 3 tracks
- Raymond Roestenburg took stage in Hall 1 and shared how to design #Actor based applications in #Akka. A full SkillsCast recording of Ray's talk can be found here: http://skillsmatter.com/podcast/home/akka-in-practise-designing-actor-based-applications/wd-8776

*David Pollak gave a talk on the recently launched web framework Lift3. A skillscast (film/code/slides) recording of this -lift talk can be found here: http://skillsmatter.com/podcast/scala/david-pollak/wd-8776

George Leontiev explained how Scala is also a logic programming language and on how Scala's type-level programming is essentially logic programming. You can watch a SkillsCast recording of George's talk (titled 'There's Prolog in your Scala') here: http://skillsmatter.com/podcast/scala/theres-a-prolog-in-your-scala/wd-8776

Following a break, featuring many discussions and visits to the booths of sponsors Cake Solutions, Pearson, Net-a-porter, Underscore, BrickAlloy BSkyB and VNGRS, continued with the following sessions:

Bill Venners got people in Hall 1 very excited with a talk on the journey from a design that leaned towards implicit conversions in ScalaTest 1.0 to one that emphasizes implicit parameters in #ScalaTest and #ScalaUtils 2.0. You can find a SkillsCast recording of Bill's truly amazing talk here: http://skillsmatter.com/podcast/home/implicit-conversions-implicit-parameters/wd-8776

Meanwhile, David Pollak explained how to craft web applications with Lift3, including instance actors that communicate between a JS client and the #Lift server. Find a SkillsCast recording of David's talk here: http://skillsmatter.com/podcast/home/lift-3-high-and-lifted-up/wd-8776

And Haoyi Li got everyone tweeting on his talk on #Metascala - a great HTML/XML construction library for Scala, that he created. Watch a SkillsCast recording of this talk on Metascala and low level stuff here: http://skillsmatter.com/podcast/home/metascala-a-tiny-diy-jvm/wd-8776

After the morning sessions and some learning and sharing of scala skills over lunch, Viktor Klang kicked off the afternoon with a talk on failure... and how to deal with it. Viktor explained that no matter how flawless and well-tested and well-typed our scala code is, there is something that we should never forget: Reality — a place where things get FUBAR all the time — so he talked about what can and will go wrong, and what strategies we have to deal with it; to recover; to heal our systems. You can watch a #SkillsCast (film/code/slides) of Viktor's keynote here: http://skillsmatter.com/podcast/home/viktor-klang/wd-8776

After Viktor's keynote, Jon Pretty gave a talk on lessons learned in #Scala API design. In his talk he explored questions like how to design a library which satisfies a dozen different use cases? How can the same API be ideal for the rigour of a mission-critical production environment, yet still perfect for quick scripting in the REPL? How can the same methods be equally well-suited to blocking and asynchronous code? How do you design an API which interacts seamlessly with a third-party library that hasn't even been conceived yet? And he did an awesome job in answering these questions by demonstrating some of Scala's more advanced features, taming #implicits, type classes and type constructors to enable every Scala user (even beginners) to benefit from some cool and cunning new patterns in library design. You can watch a SkillsCast (film/code/slides) of Jon's ScalaX talk here: http://skillsmatter.com/podcast/home/how-to-please-everyone-all-the-time-lessons-in-scala-api-design/wd-8776

And Chris Cundill from Cake Solutions talked about #thisweekinscala, the weekly community blog on the latest Scala releases, news, blogs, presentations and tutorials. A SkillsCast recording (film/code/slides) of Chris' talk can be found here: http://skillsmatter.com/podcast/home/thisweekinscala/wd-8776

It was nice to see #Scala powering some of the most successful UK startups, MindCandy and Net-a-porter, and to see their teams sharing their experience with us.

Sean Parsons from MindCandy talked about #Types in #Functional Programming. Sean shared some of the experience he gained at MindCandy to explain why you should use Types to model the logic you intend to code more accurately and succinctly. Check out the SkillsCast (film/code/slides) recording of Sean's talk here: http://skillsmatter.com/podcast/home/let-the-types-set-you-free/wd-8776

And Ariel Kogan & Ian Forsey shared their skills and experience gained at Net-a-porter, where they created their first reactive #Scala / #Akka / #Spray service. They explained what they learned, introducing these technologies at a company with a long-standing Java codebase and production infrastructure. You can watch a SkillsCast recording of their talk here: http://skillsmatter.com/podcast/home/scala-does-the-catwalk/wd-8776

Many of the popular talks at the Scala eXchange featured live coding - and a great example of a brilliant live coding session was Mathias Doenitz's live coding demo on #Spray, showing how to use Spray to build REST/HTTP-based integration layers on top of #Akka. Matthias showed how easy it is to to send an HTTP request and receive HTTP responses on the client-side, write a low-level HTTP server as well as use the high-level routing DSL on the server-side to define a simple #REST API behavior. Watch Mathias "live" coding session here: http://skillsmatter.com/podcast/home/mathias-doenitz/wd-8776

Scala Macros were a very hot topic at ScalaX - and Eugene Burmako gave a really good introduction, explaining what #ScalaMacros are, and in what capacity the notion of compile-time metaprogramming can be useful to you, on a series of concrete use cases from research and industry. In the SkillsCast recording of Eugene's talk, you will see how #Slick #Play #Shapeless #Akka #Pickling #Async #Specs and others use macros and you will learn how to apply those techniques. You can watch a SkillsCast (film/code/slides) of Eugene's #ScalaX talk here: http://skillsmatter.com/podcast/home/what-are-macros-good-for/wd-8776

And Alexander Nemish talked about #JScala, a Scala macro that produces #JavaScript from #Scala code. Alexander used a fully working Tetris example (written in Scala with to JavaScript - very cool) to show JScala features. You can watch Alexander's talk here: http://skillsmatter.com/podcast/home/jscala-write-your-javascript-in-scala/wd-8776

Continuing the #JavaScript theme, Sebastien Doeraene gave a talk on Scala.JS and how to write Rich Internet Applications in Scala, enjoying all the Scala goodness, without sacrificing JavaScript interoperability. So if you like to learn how to write Scala for the browser, check out this SkillsCast recording (film/code/slides) of Sebastien's ScalaX talk here: http://skillsmatter.com/podcast/home/scala-js-write-in-scala-for-the-browser-4567/wd-8776

Finally, the brilliant(!) Fredrik Ekholdt gave a great talk on his project #Adept, providing a new dependency management system for the #JVM. Fredrik explained what Adept is, why you should care and how you can help him and the Adept team. So if you want to learn all about Adept, watch the skillscast recording of his talk here: http://skillsmatter.com/podcast/home/introducing-adept-4573/wd-8776

We finished a day with the Scala eXchange Panel discussion, whilst enjoying some beers and nibbles... it was a bit noisy, so the recording will need some work before it can be published... I wil post here once it is ready..

WISH YOU WERE THERE? JOIN US IN 2014 ON DECEMBER 8-9TH
Make sure to attend next year! 2014 has just been announced for December 8 and 9th in London – and next year Martin Odersky will join us to give a visionary keynote! Tickets are available already, and if you register by mid february, you can get a ticket for just £195 (+VAT)! So if you fancy joining a gathering of 500+ fellow developers passionate about Scala, Reactive Programming and all things Functional, check out next year's pages today! http://skillsmatter.com/event/scala/scala-exchange-2014/wd-8776

That's all I've got so far... find further updates here or on twitter #scalax I'll do a post on Day to of ScalaX soon!

Wendy
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Progress may seem a bit slow recently, but I have been trying to rework the TokenUtils approach, because it is a kludge and makes adjusting layout messier than it should be.

My intention is to make use of multirec to enable annotations on the GHC AST (via the Annotations package on hackage).

This will allow the tokens for a specific AST fragment to be spread down to the leaves of the tree, and the relationship between parts to be expressed in some kind of prettyPrint offset format.

Hence refactoring the AST will automatically bring the tokens along.

The only problem is that the GHC AST is big. The multirec-alt-deriver can do it via TH, but it requires around 7G of RAM in the process.

I have had similar experience with the approach captured in the 'Generic Generic Deriving' paper.

I think my next step will be to try and emit source code based on either the generic or TH approach, so that the generation step only needs to be done once on a beefy machine.

Any advice on alternate approaches is welcomed.

The multeric-alt-deriver version is at https://github.com/alanz/ghc-multirec
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Update. ghc-mod now exposes an internal interface to be able to detect the project environment and this is integrated into HaRe.

A final cleanup of the token output formatting is taking longer than anticipated, but is nearly done. Hopefully there will be something to see later today.

It has brought to light an oversight in re-aligning layout on a renaming where the length of the identifier changes, and requires changes to do/where/let clauses to retain semantics.

I intend putting out a version without that being fixed, as a preview.
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
We have reached a milestone, in that there is an early stage pre-alpha version of HaRe

The master branch of https://github.com/alanz/HaRe can now install as version 0.7 of HaRe, and has emacs integration for an initial set of refactorings, namely

  Duplicate a definition
  Lift a definition one level
  Lift a definition to the top
  Demote a definition
  Convert an if statement to a case statement.

It has been tested with GHC 7.6.3 HP 2013-2 on emacs24 (Linux)
3
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
 
My VPT talk on building trustworthy refactoring tools.  http://www.cs.kent.ac.uk/people/staff/sjt/presentations/VPTtalk.pdf
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
The zipper approach is bearing fruit on the LiftOneLevel refactoring, where once the location of the declaration to be lifted is found, the zipper is traversed upward to find the nearest enclosing HSValBinds as the new home for the declaration.

The code is on this branch https://github.com/alanz/HaRe/tree/wip
1
Add a comment...

Adam Bell

Discussion  - 
 
How do I add the prelude in HaRe  (from master here : https://github.com/alanz/HaRe )?  I'm trying to test the refactorings with a simple file but only getting:

"Source files missing for (add files with 'pfe add' or 'pfe chase'):
    Prelude, needed by Main{-/home/adam/sandbox/haskell/simple/Geometry.hs-}"

Update: I figured it out.  cabal install it and then 'customize" in gvim and set HaskelLibraries path to /Share/HaRe-.../
1
AlanKim Zimmerman's profile photoAdam Bell's profile photo
2 comments
 
Awesome, I look forward to it being prime time. The master branch mainly works, one change to get it building on ghc 7.4 and then just figuring out how it works.
Add a comment...

About this community

The Haskell Refactoring tool https://github.com/alanz/HaRe

AlanKim Zimmerman
owner

Discussion  - 
 
HaRe Version 0.7.1.1 corrects the target file path construction by using the cabal file path rather than the current directory path.
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Version 0.7.0.9 is out.

It is basicaly just tweaks based on some real world use.

I am now eating my own dogfood, and managed to successfully rename variables to get rid of the name shadowing warnings.

The lift and demote refactorings still seem to have some issues, but I will not be able to get to them until late Jan.
2
1
Rob Stewart's profile photo
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
A friend of mine is studying graphic design and I asked him to come up with a logo for the Haskell Refactorer. I asked him to base it on a hare, as it is pronounced by Simon Thompson, and the concept of changing haskell.

Please provide feedback/suggestions/criticism on it
3
1
AlanKim Zimmerman's profile photoChristopher Brown's profile photoFrancisco M. Soares Neto's profile photo
2 comments
 
I like it a lot! It's cute! :) 
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Version 0.7.0.1 is on hackage, there were some dependencies in the elisp on functions from the Wrangler Erlang refactorer which have been removed.
2
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Version 0.7.0.0 is now on hackage.

It has an issue where it does not adjust layout when renaming and the new name is a different length, this is the next item to be addressed.
2
Add a comment...
 
The current master at https://github.com/alanz/HaRe has the renaming refactoring implemented, including elisp.

A little more cleaning up, and then HaRe 0.7 will be coming to hackage, with the following initial refactorings

       iftocase
           Convert an if expression to a case expression

       dupdef
           Duplicate a definition

       liftToTopLevel
           Lift a declaration to the top level

       liftOneLevel
           Lift a declaration one level

       demote
           Move a declaration down one level

       rename
           Rename an identifier
2
1
AlanKim Zimmerman's profile photoRob Stewart's profile photo
2 comments
 
Ok, ghc-mod is in (branch ghc-mod-cradle) but needs a new release of ghc-mod.

Testing against real code also showed up a massive time problem due to the MonadPlus definition for RefactGhc, which basically re-initialise a GHC session every time mplus is called. Moved those routines into the Maybe monad instead, much faster.

One or two other funnies have shown up, should be dealt with in a day or so, and hoping to get something out be end of the weekend
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
I have finished the port of the MoveDef refactoring.

Next step is to revisit the TokenUtils to sort out the formatting of output especially when tokens are deleted, and then to aim for some kind of release.

I think the underlying API is now basically stable, part of the release process will be to strip out all the residual cruft that is no longer needed.
2
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
I have written a blog post on my experiences getting the syz package to operate over the GHC AST for HaRe.

It is currently a proof-of-concept, but I think it may add some tools for relative movement in the AST while refactoring.

http://alanz.github.io/haskell%20refactorer/2013/06/18/scrap-your-zippers-and-ghc
2
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
Now that the Haskell Platform 2013.2.0.0 is officially out I am going to  start switching the active code base to support it. The work will be on branch hp2013-2 in my repository.
1
Add a comment...

AlanKim Zimmerman
owner

Discussion  - 
 
I am struggling to line up the types for this replacement. Does anyone know how to do it?
http://hpaste.org/86675?
1
Add a comment...