Wednesday, July 3, 2013

Quick Update: Improved Interactive Solver

In the past two weeks, I have refactored the dependency resolver a bit.
For example, in Dependency.hs there is a function called "resolveDependencies".
It now takes an optional parameter, which is a "Pointer QGoalReasonChain" (or QPointer) which tells it that it should only resolve whatever is left below that pointer, hence keeping the choices made there.

The Interactive Solver is now started in Install.hs' makeInstallPlan.
However, it checks so in a very pedantic way:

    if fromFlag (installInteractive installFlags) && solver == Modular -- How could this be handled better?
      then do
        notice verbosity "Starting interactive dependency solver..."
        mptr <- runInteractive platform (compilerId comp) solver resolverParams
        case mptr of
            Nothing -> return Nothing                   -- The user does not want to install anything.
            x       -> return $ Just (resolveUsing x)
The case-analysis could be replaced by something shorter,
        return $ mptr >>= return . resolveUsing . return
but I have been told that this is not very readable. ;-) (Possibly hinting at a bad design..)

I will have to look for a better integration..

Also, I have tried to improve the output of the solver, implemented some more commands, (install works now!) and the IDE knows about autocomplete-on-tab now.

Here is the example session:
(If you want to try this: the IDE assumes a terminal with 100 characters worth of width)

cabal install snap --interactive 
Starting interactive dependency solver...
Welcome to cabali!
This interface accepts simple commands separated by ';'. E.g. go 1 ; auto
go n            chooses n - alternatively "n" does the same. Just Enter, picks the first choice
up              goes up one step
top             goes all the way to the top
auto            starts the automatic solver
goto aeson      runs the parser until it sets aeson's version
goto aeson:test runs the parser until it sets the flag test for aeson
prefer aeson    sorts the choices so that aeson comes first if it is available (Same arguments as goto)
bset name       sets a bookmark called name
blist           lists all bookmarks
bjump name      jumps to the bookmark name
indicateAuto    indicates the choices the solver would have made with a little (*)
install         Once the interface says 'Done', you can type 'install' to install the package
showPlan        shows what is going to be installed/used
Missing dependencies
(1) snap   

> 1
Version of snap
(1) 0.12.0     (2) 0.11.3.1   (3) 0.11.3     (4) 0.11.2.2   (5) 0.11.2.1   (6) 0.11.2     (7) 0.11.1     
(8) 0.11.0     (9) 0.10.0.1   (10) 0.10.0    (11) 0.9.2.2   (12) 0.9.2.1   (13) 0.9.2     (14) 0.9.1.1   
(15) 0.9.1     (16) 0.9.0.1   (17) 0.9.0     (18) 0.8.1     (19) 0.8.0.2   (20) 0.8.0.1   (21) 0.8.0     
(22) 0.7       (23) 0.6.0.2   (24) 0.6.0.1   (25) 0.6.0     (26) 0.5.5.1   (27) 0.5.5     (28) 0.5.4     
(29) 0.5.3.1   (30) 0.5.3     (31) 0.5.2     (32) 0.5.1.3   (33) 0.5.1.2   (34) 0.5.1.1   (35) 0.5.1     
(36) 0.5.0     (37) 0.4.3     (38) 0.4.2     (39) 0.4.1     (40) 0.4       (41) 0.3.1     (42) 0.3.0.1   
(43) 0.3.0     

> 1
Missing dependencies
(1) base                         (2) snap-0.12.0:old-base         (3) template-haskell             
(4) old-time                     (5) snap-0.12.0:old-base         (6) xmlhtml                      
(7) vector-algorithms            (8) vector                       (9) unordered-containers         
(10) transformers                (11) time                        (12) text                        
(13) syb                         (14) stm                         (15) snap-server                 
(16) snap-core                   (17) regex-posix                 (18) pwstore-fast                
(19) mwc-random                  (20) mtl                         (21) logict                      
(22) heist                       (23) hashable                    (24) filepath                    
(25) errors                      (26) dlist                       (27) directory-tree              
(28) directory                   (29) containers                  (30) configurator                
(31) comonad                     (32) clientsession               (33) cereal                      
(34) bytestring                  (35) attoparsec                  (36) aeson                       
(37) MonadCatchIO-transformers   

> indicateAuto
Missing dependencies
(1) base (*)                     (2) snap-0.12.0:old-base         (3) template-haskell             
(4) old-time                     (5) snap-0.12.0:old-base         (6) xmlhtml                      
(7) vector-algorithms            (8) vector                       (9) unordered-containers         
(10) transformers                (11) time                        (12) text                        
(13) syb                         (14) stm                         (15) snap-server                 
(16) snap-core                   (17) regex-posix                 (18) pwstore-fast                
(19) mwc-random                  (20) mtl                         (21) logict                      
(22) heist                       (23) hashable                    (24) filepath                    
(25) errors                      (26) dlist                       (27) directory-tree              
(28) directory                   (29) containers                  (30) configurator                
(31) comonad                     (32) clientsession               (33) cereal                      
(34) bytestring                  (35) attoparsec                  (36) aeson                       
(37) MonadCatchIO-transformers   

> prefer stm
Missing dependencies
(1) stm                          (2) base (*)                     (3) snap-0.12.0:old-base         
(4) template-haskell             (5) old-time                     (6) snap-0.12.0:old-base         
(7) xmlhtml                      (8) vector-algorithms            (9) vector                       
(10) unordered-containers        (11) transformers                (12) time                        
(13) text                        (14) syb                         (15) snap-server                 
(16) snap-core                   (17) regex-posix                 (18) pwstore-fast                
(19) mwc-random                  (20) mtl                         (21) logict                      
(22) heist                       (23) hashable                    (24) filepath                    
(25) errors                      (26) dlist                       (27) directory-tree              
(28) directory                   (29) containers                  (30) configurator                
(31) comonad                     (32) clientsession               (33) cereal                      
(34) bytestring                  (35) attoparsec                  (36) aeson                       
(37) MonadCatchIO-transformers   

> indicateAuto
Missing dependencies
(1) stm (*)                      (2) base                         (3) snap-0.12.0:old-base         
(4) template-haskell             (5) old-time                     (6) snap-0.12.0:old-base         
(7) xmlhtml                      (8) vector-algorithms            (9) vector                       
(10) unordered-containers        (11) transformers                (12) time                        
(13) text                        (14) syb                         (15) snap-server                 
(16) snap-core                   (17) regex-posix                 (18) pwstore-fast                
(19) mwc-random                  (20) mtl                         (21) logict                      
(22) heist                       (23) hashable                    (24) filepath                    
(25) errors                      (26) dlist                       (27) directory-tree              
(28) directory                   (29) containers                  (30) configurator                
(31) comonad                     (32) clientsession               (33) cereal                      
(34) bytestring                  (35) attoparsec                  (36) aeson                       
(37) MonadCatchIO-transformers   

> goto dlist
dlist (needed by snap-0.12.0)
(1) 0.5 (*)    (2) 0.4.1 (F)  (3) 0.4 (F)    (4) 0.3.2 (F)  (5) 0.3.1 (F)  (6) 0.3 (F)    (7) 0.2 (F)    

> 1
Missing dependencies
(1) dlist-0.5:applicative-in-base (*)  (2) dlist-0.5:applicative-in-base      
(3) directory-tree                     (4) directory                          
(5) containers                         (6) configurator                       
(7) comonad                            (8) clientsession                      
(9) cereal                             (10) bytestring                        
(11) attoparsec                        (12) aeson                             
(13) MonadCatchIO-transformers         

> auto
Created a valid installplan. 
Type install to install, or showPlan to review
No choices left
> 

No comments:

Post a Comment