On Sat, Oct 18, 2008 at 12:37 PM, David Roundy <[EMAIL PROTECTED]> wrote:

>
> > Which is another problem I had.  Trying to understand what setup.hs does
> > has been difficult.  I had to read the entire source of Franchise twice
> > before I could figure out any part of what setup.hs is doing, and I still
> > don't know how to extend setup.hs.  The heavy use of operators and
> > redefined Haskell98 functions made the source hard for me to
> > read[1]. Only one module, Util.hs, seems to have any source level
> > documentation.  But, all that aside, the really hard to grok part is the
> > undocumented mutually recursive datastructures that sit at the heart of
> > franchise.  Unfortunately, as a user of setup.hs you need to understand
> > them because they are exposed at that level currently.  I forget what the
> > types are called but it's the ones that use (:<), (:<-), and (|<-) as
> > constructors.  You can see them at use in setup.hs.  The impression given
> > there is that they hide some sort of magic.
>
> For almost all uses, you don't need to understand the dependency and make
> rules, and I'll welcome suggestions for improvements (preferably to the
> franchise mailing list).


I have no idea where that is, so I'll just continue here.  My first advice
would be to either heavily justify the need for mutually recursive data
structures and document them accordingly or avoid them.  They put
considerable cognitive load on developers, so if they aren't necessary let's
try to simplify a bit.


>  :< is the equivalent of ':' in a makefile,
> separating a target from its dependencies, and :<- and |<- are both the
> something like a tab, in that they connect a target-dependency relationship
> with a rule for building the target from its dependencies.


Wouldn't it be simpler to use a familiar data structure such as a graph?
The talk Duncan gave about Cabal touched on the (somewhat well known) idea
that make is based on graphs of dependencies:
http://www.galois.com/~dons/slides/08-10-dcoutts.pdf
Although I don't know how much the slides talk about it.


> > [1] endsWith/beginsWith/startsWith all seem to be equivalent to functions
> > found in the Haskell98 report.  By giving new definitions of these
> functions
> > I was tricked into reading their definitions and trying to understand
> *how*
> > they differ in behavior from the isSuffixOf and isPrefixOf.  I have
> patches
> > that replace the home grown versions with the ones from Data.List if
> anyone
> > wants them.
>
> You are welcome to send patches in, but patches that add new dependencies
> won't be accepted.  I avoided using Data.List because I didn't know if it
> was likely to be moved out of base.  And one of the points of franchise is
> to be portable from one version of ghc to another.


Attached.  No new dependencies were added.  Franchise is already using
Data.List, but if you don't like the patches, I don't need to know about it
as I won't be amending them.  I only created them to help me understand
setup.hs.

Thanks,
Jason
Fri Oct 17 22:14:48 PDT 2008  Jason Dagit <[EMAIL PROTECTED]>
  * use Haskell98 list functions

Fri Oct 17 22:36:33 PDT 2008  Jason Dagit <[EMAIL PROTECTED]>
  * it's unreasonable to install during test

Fri Oct 17 22:40:41 PDT 2008  Jason Dagit <[EMAIL PROTECTED]>
  * use isSuffixOf in more places

New patches:

[use Haskell98 list functions
Jason Dagit <[EMAIL PROTECTED]>**20081018051448] hunk ./Distribution/Franchise/Buildable.hs 49
     where
 
 import Control.Monad ( when, msum )
-import Data.List ( nub, partition, delete, intersect )
+import Data.List ( nub, partition, delete, intersect, isPrefixOf )
 import System.Environment ( getProgName )
 import System.Directory ( doesFileExist, removeFile, copyFile,
                           getModificationTime, findExecutable )
hunk ./Distribution/Franchise/Buildable.hs 343
                            io $ writeFile fn $ repl r x
     where repl [] x = x
           repl ((a,b):rs) x = repl rs $ r1 a b x
-          r1 a b x@(x1:xs) | startsWith a x = b ++ r1 a b (drop (length a) x)
+          r1 a b x@(x1:xs) | a `isPrefixOf` x = b ++ r1 a b (drop (length a) x)
                            | otherwise = x1 : r1 a b xs
           r1 _ _ "" = ""
hunk ./Distribution/Franchise/Buildable.hs 346
-          startsWith [] _ = True
-          startsWith (c:cs) (d:ds) = c == d && startsWith cs ds
-          startsWith _ _ = False
 
 define :: String -> C ()
 define x = do ghcFlags ["-D"++x]
hunk ./Distribution/Franchise/Util.hs 44
 import System.IO ( hFlush, stdout, hGetContents )
 import Control.Concurrent ( forkIO )
 import Control.Monad ( when )
+import Data.List ( isPrefixOf, isSuffixOf )
 
 import Distribution.Franchise.ConfigureState
 
hunk ./Distribution/Franchise/Util.hs 52
 beginsWith :: String -- ^ Prefix that might be there
            -> String -- ^ String to check against
            -> Bool   
-beginsWith x y = take (length x) y == x
+beginsWith = isPrefixOf
 
 -- | Checks if a string ends with a given string
 endsWith :: String -- ^ Suffix that might be at the end of a string
hunk ./Distribution/Franchise/Util.hs 58
          -> String -- ^ String to check against
          -> Bool
-endsWith x y = drop (length y - length x) y == x
+endsWith = isSuffixOf
 
 -- | Checks if a string ends with any given suffix
 endsWithOneOf :: [String] -- ^ List of strings to check
[it's unreasonable to install during test
Jason Dagit <[EMAIL PROTECTED]>**20081018053633] changepref test
runhaskell Setup.hs configure --user --prefix=$HOME && runhaskell Setup.hs build && runhaskell Setup.hs clean
runhaskell Setup.hs configure --user --prefix=$HOME && runhaskell Setup.hs build && runhaskell Setup.hs clean
changepref test
runhaskell Setup.hs configure --user --prefix=$HOME && runhaskell Setup.hs build && runhaskell Setup.hs clean && runhaskell Setup.hs install
runhaskell Setup.hs configure --user --prefix=/Users/dagit && runhaskell Setup.hs build && runhaskell Setup.hs clean
[use isSuffixOf in more places
Jason Dagit <[EMAIL PROTECTED]>**20081018054041] hunk ./Distribution/Franchise/Buildable.hs 49
     where
 
 import Control.Monad ( when, msum )
-import Data.List ( nub, partition, delete, intersect, isPrefixOf )
+import Data.List ( nub, partition, delete, intersect, isPrefixOf, isSuffixOf )
 import System.Environment ( getProgName )
 import System.Directory ( doesFileExist, removeFile, copyFile,
                           getModificationTime, findExecutable )
hunk ./Distribution/Franchise/Buildable.hs 112
 printBuildableDeep (Unknown _) = error "bug in printBuildableDeep"
 
 rm :: String -> C ()
-rm f | endsWith "/" f = return ()
+rm f | "/" `isSuffixOf` f = return ()
 rm f = io (removeFile f) `catchC` \_ -> return ()
 
 depName :: Dependency -> [String]
hunk ./Distribution/Franchise/Ghc.hs 45
 
 import Control.Monad ( when )
 import Data.Maybe ( catMaybes, listToMaybe )
-import Data.List ( partition, (\\) )
+import Data.List ( partition, (\\), endsWith )
 import System.Directory ( createDirectoryIfMissing, copyFile )
 
 import Distribution.Franchise.Util
replace ./Distribution/Franchise/Ghc.hs [A-Za-z_0-9] endsWith isSuffixOf
hunk ./Distribution/Franchise/Util.hs 34
 POSSIBILITY OF SUCH DAMAGE. -}
 
 module Distribution.Franchise.Util ( system, systemOut, systemErr, cd, cat,
-                                     beginsWith, endsWith, endsWithOneOf )
+                                     endsWithOneOf )
     where
 
 import System.Directory ( setCurrentDirectory )
hunk ./Distribution/Franchise/Util.hs 48
 
 import Distribution.Franchise.ConfigureState
 
--- | Checks if a string begins with a given string
-beginsWith :: String -- ^ Prefix that might be there
-           -> String -- ^ String to check against
-           -> Bool   
-beginsWith = isPrefixOf
-
--- | Checks if a string ends with a given string
-endsWith :: String -- ^ Suffix that might be at the end of a string
-         -> String -- ^ String to check against
-         -> Bool
-endsWith = isSuffixOf
-
 -- | Checks if a string ends with any given suffix
 endsWithOneOf :: [String] -- ^ List of strings to check
               -> String   -- ^ String to check against
hunk ./Distribution/Franchise/Util.hs 52
               -> Bool
-endsWithOneOf xs y = any (\x -> endsWith x y) xs
+endsWithOneOf xs y = any (\x -> x `isSuffixOf` y) xs
 
 -- | Run a command
 system :: String   -- ^ Command

Context:

[Check environment for ProgramFiles
J. Garrett Morris <[EMAIL PROTECTED]>**20081017164748
 On Windows, if the user hasn't specified a prefix, we look for the environment
 variable ProgramFiles before defaulting to C:\Program Files.  This should allow
 us to handle cases where programs are stored in a non-standard location.
] 
[add withLib for checking libraries we don't depend on.
David Roundy <[EMAIL PROTECTED]>**20081017122024
 Ignore-this: 6d2588ae1b9acb792ff78aa337cc4be4
 It's a simple shorthand for
  do checkLib ...
     xxx
  `catchC` \_ -> putS "... not found"
] 
[change getopts handling to allow actions when a flag isn't present.
David Roundy <[EMAIL PROTECTED]>**20081016195930
 Ignore-this: 46c946d7d400a3095315f484e0819ccc
 Previously it was necessary to use addExtraData to do something when a
 flag is *not* present.  Now users can just use unlessFlag to
 accomplish the same task.
] 
[update imports so that franchise no longer depends on the haskell98 package
Austin Seipp <[EMAIL PROTECTED]>**20081016012637] 
[avoid redundancy by checking that we can make the build while configuring.
David Roundy <[EMAIL PROTECTED]>**20081015235134
 Ignore-this: 933d254981169dfec818f3f86279d1df
 This makes the examples simpler, and generally avoids the possibility of
 configure succeeding when we don't have the modules needed to build.  It may
 still be helpful to be able to call findPackagesFor, if we want to change
 the compilation based on the success of that command.
] 
[add some simple examples of using franchise
Austin Seipp <[EMAIL PROTECTED]>**20081015233536] 
[add functions to search for functionality within a module.
David Roundy <[EMAIL PROTECTED]>**20081014201409
 Ignore-this: a05bb7f14c155956bda9fcb8088cf109
] 
[define whenC like unlessC.
David Roundy <[EMAIL PROTECTED]>**20081014161830
 Ignore-this: 5d5996d4ac48d89112d7dba1241e0670
] 
[add checkHeader to look for just a header file.
David Roundy <[EMAIL PROTECTED]>**20081014154945
 Ignore-this: 21e13df433dcddc1cb93facfaeb33a81
] 
[remove trailing whitespace.
David Roundy <[EMAIL PROTECTED]>**20081014154858
 Ignore-this: 156012adf3cc323c7ba6aa270952293a
] 
[fix  bug in  #ifdef  (which should have been #if)
David Roundy <[EMAIL PROTECTED]>**20081014120209
 Ignore-this: bf3cf1d0779d83faf6c2e23951aa7a6f
] 
[first batch of docs; documented Util.hs first
Austin Seipp <[EMAIL PROTECTED]>**20081014064708] 
[avoid '-optdep-f' in favor of '-dep-makefile' if we have ghc >= 6.10
Austin Seipp <[EMAIL PROTECTED]>**20081013195209] 
[just use catch from the Prelude.
David Roundy <[EMAIL PROTECTED]>**20081013202527
 Ignore-this: 708dbb4286230ffad0b383348bd93c97
] 
[TAG 0.0.3
David Roundy <[EMAIL PROTECTED]>**20081013174537
 Ignore-this: b66143777ecd6dadfe75b1095db3e630
] 
Patch bundle hash:
cb5442b5f7686f4a8b4a969b7b0ae65612a6041a
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to