which (empty) → 0.1.0.0
raw patch · 6 files changed
+96/−0 lines, 6 filesdep +basedep +shellydep +template-haskellsetup-changed
Dependencies added: base, shelly, template-haskell, text
Files
- ChangeLog.md +1/−0
- LICENSE +30/−0
- README.md +3/−0
- Setup.hs +2/−0
- src/System/Which.hs +30/−0
- which.cabal +30/−0
+ ChangeLog.md view
@@ -0,0 +1,1 @@+# Revision history for dependent-monoidal-map
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2019, Obsidian Systems LLC++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Obsidian Systems LLC nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# which [](https://travis-ci.org/obsidiansystems/which)++`which` is a Haskell library that provides functionality similar to its [\*nix namesake](https://en.wikipedia.org/wiki/Which_(command)) on the command line. You can use this library to determine the full path of a command that will be executed by your Haskell program.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/System/Which.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}+module System.Which where++import qualified Shelly as Sh+import qualified Data.Text as T+import Language.Haskell.TH (Exp, Q, reportError, runIO)+import Data.Monoid ((<>))+import Data.List (isPrefixOf)++-- | Determine which executable would run if the given path were executed, or return Nothing if a suitable executable cannot be found+which :: FilePath -> IO (Maybe FilePath)+which f = fmap (fmap (T.unpack . Sh.toTextIgnore)) $ Sh.shelly $ Sh.which $ Sh.fromText $ T.pack f++-- | Run `which` at compile time, and substitute the full path to the executable.+--+-- This is useful in NixOS to ensure that the resulting executable contains the dependency in its closure and that it refers to the same version at run time as at compile time+staticWhich :: FilePath -> Q Exp+staticWhich f = do+ mf' <- runIO $ which f+ case mf' of+ Nothing -> compileError $ "Could not find executable for " <> show f+ Just f'+ | "/nix/store/" `isPrefixOf` f' -> [| f' |]+ | otherwise -> compileError $ "Path to executable " <> show f <> " was found in " <> show f' <> " which is not in /nix/store. Be sure to add the relevant package to 'backendTools' in default.nix."++ where+ compileError msg' = do+ let msg = "staticWhich: " <> msg'+ reportError msg+ [| error msg |]
+ which.cabal view
@@ -0,0 +1,30 @@+name: which+version: 0.1.0.0+license: BSD3+license-file: LICENSE+author: Obsidian Systems LLC+maintainer: maintainer@obsidian.systems+copyright: 2019 Obsidian Systems LLC+build-type: Simple+extra-source-files: ChangeLog.md README.md+cabal-version: >=1.10+category: System+synopsis: Determine the full path to an executable.+description: Determine the full path to an executable, similar to the *nix "which" command.+tested-with:+ GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5++library+ exposed-modules: System.Which+ build-depends:+ base >= 4.9.0 && < 4.13,+ shelly >= 1.8.0 && < 1.10,+ text >= 1.2.3 && < 1.3,+ template-haskell >= 2.11.0 && < 2.15++ hs-source-dirs: src+ default-language: Haskell2010++source-repository head+ type: git+ location: https://github.com/obsidiansystems/which