ennocramer / floskell

Floskell is a flexible Haskell source code pretty printer.
BSD 3-Clause "New" or "Revised" License
178 stars 22 forks source link

Flexible imports and impossible stuff #40

Open kanashimia opened 4 years ago

kanashimia commented 4 years ago

This:

hmm better
import           Control.Concurrent.Async
import           Graphics.Rendering.OpenGL
import           Graphics.UI.GLUT
-- same imports, but with qualified import Control.Concurrent.Async import Graphics.Rendering.OpenGL import qualified Graphics.UI.GLUT
import Control.Concurrent.Async
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
-- same imports, but with qualified import Control.Concurrent.Async import Graphics.Rendering.OpenGL import qualified Graphics.UI.GLUT
createWindowAndStuff title = do
    createWindow title
    windowSize $= Size 800 500
    displayCallback $= displaySomething
      
createWindowAndStuff title = do
    createWindow title
    windowSize      $= Size 800 500
    displayCallback $= displaySomething
      
somePoints :: [(Float, Float)]
somePoints = [ (-0.25, 0.25)
             , (0.75, 0.35)
             , (0.75, -0.15)
             , (-0.75, -0.25)
             , (0.75, 0.35)
             , (0.75, -0.15)
             , (-0.75, -0.25)
             ]
      
somePoints :: [(Float, Float)]
somePoints = [ (-0.25,  0.25)
             , ( 0.75,  0.35)
             , ( 0.75, -0.15)
             , (-0.75, -0.25)
             , ( 0.75,  0.35)
             , ( 0.75, -0.15)
             , (-0.75, -0.25)
             ]
      
somePoints :: [(Float, Float)]
somePoints = [ (-0.25, 0.25) :: (Float, Float)
             , (0.75, 0.35) :: (Float, Float)
             , (0.75, -0.15) :: (Float, Float)
             , (-0.75, -0.25) :: (Float, Float)
             , (0.75, 0.35) :: (Float, Float)
             , (0.75, -0.15) :: (Float, Float)
             , (-0.75, -0.25) :: (Float, Float)
             ]
      
somePoints :: [(Float, Float)]
somePoints = [ (-0.25, 0.25)  :: (Float, Float)
             , (0.75, 0.35)   :: (Float, Float)
             , (0.75, -0.15)  :: (Float, Float)
             , (-0.75, -0.25) :: (Float, Float)
             , (0.75, 0.35)   :: (Float, Float)
             , (0.75, -0.15)  :: (Float, Float)
             , (-0.75, -0.25) :: (Float, Float)
             ]
      


Imports one would be very easy to implement - others are very tricky, especially considering that it should work for any lists and data constructors.

That one in the do expression should be configurable for each operator like (<-,$...).

There is extension with similar alignment functionality for vs code.



-- I don't really know any formatter that does this, so this isn't world's first feature by any means.