mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 10:46:11 +03:00
bfa019997a
* Initial rattle prototype * Build the IDE core * Ignore the Rattle directory * Clean up the dependencies * Require stack-1.10, since that does much better extra-dep caching * Streamline the ghc-lib dependencies * Compile more pieces * Add a build.bat * Make the Windows build use the correct stack.yaml to bootstrap * Fix up enough to build on Windows * Generate the dylib's on Mac * Remove accidental -v * Make the Haskell build driven by the Bazel metadata * Get proto3-suite building * Delete the unneeded haskell-dependencies * Allow generating the proto files and compiling them * Fix metadata to deal with """ syntax * Fix metadata to deal with a list of globs * More work in the direction of daml-ghc * Use correct daml_lf proto version * Tell GHC to use shared objects in TH * Specify needed packages * wip * wip * Switch to the fork of gRPC-haskell * Build executables with rattle * setup build.sbt in daml-lf * Build binaries with rattle * rattle-sbt, move scala build scripts out of daml-lf subdir, and into rattle subdir * convert scala-build.sh into MainScala.hs * Clean up rattle build * Pre-merge clean up * Switch to the newer version of ghc-lib-parser * remove dev ls from MainScala.hs * compile java generated from protos as separate projects * Add copyright headers * HLint fixes * Uscrewup an HLint fix * fix scala formatting of rattle/build.sbt
27 lines
814 B
Haskell
27 lines
814 B
Haskell
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
-- SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
module Util(topSort, transitive) where
|
|
|
|
import Data.Tuple.Extra
|
|
import Data.List
|
|
import Data.Maybe
|
|
|
|
|
|
topSort :: (Show k, Eq k) => [(k, [k], v)] -> [v]
|
|
topSort [] = []
|
|
topSort xs
|
|
| null now = error $ "topSort failed to order things\n" ++ unlines (map (\(a,b,_) -> show (a,b)) xs)
|
|
| otherwise = map thd3 now ++ topSort [(k, ks \\ map fst3 now, v) | (k, ks, v) <- later]
|
|
where (now,later) = partition (null . snd3) xs
|
|
|
|
|
|
transitive :: Ord k => [(k, [k])] -> k -> [k]
|
|
transitive xs k = f [] [k]
|
|
where
|
|
f seen [] = seen
|
|
f seen (t:odo)
|
|
| t `elem` seen = f seen odo
|
|
| otherwise = f (t:seen) (fromMaybe [] (lookup t xs) ++ odo)
|