open-browser (empty) → 0.1.0.0
raw patch · 5 files changed
+93/−0 lines, 5 filesdep +basedep +open-browserdep +processsetup-changed
Dependencies added: base, open-browser, process
Files
- LICENSE +30/−0
- Setup.hs +2/−0
- example/Main.hs +8/−0
- lib/Network/Browser.hs +24/−0
- open-browser.cabal +29/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, rightfold++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 rightfold 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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ example/Main.hs view
@@ -0,0 +1,8 @@+module Main+( main+) where++import Network.Browser (openBrowser)++main :: IO ()+main = openBrowser "http://haskell.org/" >>= print
+ lib/Network/Browser.hs view
@@ -0,0 +1,24 @@+module Network.Browser+( openBrowser+) where++import System.Exit (ExitCode(..))+import System.Process (rawSystem)++osxCommand :: String -> (String, [String])+osxCommand url = ("/usr/bin/osascript", argv)+ where argv = ["-e", appleScript, url]+ appleScript = "on run argv\n\+ \ open location (item 1 of argv)\n\+ \end run\n"++osx :: String -> IO Bool+osx url = exitCodeToBool `fmap` rawSystem executable argv+ where (executable, argv) = osxCommand url+ exitCodeToBool ExitSuccess = True+ exitCodeToBool (ExitFailure _) = False++-- |'openBrowser' opens a URL in the user's preferred web browser. Returns+-- whether or not the operation succeeded.+openBrowser :: String -> IO Bool+openBrowser = osx
+ open-browser.cabal view
@@ -0,0 +1,29 @@+name: open-browser+version: 0.1.0.0+synopsis: Open a web browser from Haskell.+description: Open a web browser from Haskell.+ Currently only OS X is supported.+license: BSD3+license-file: LICENSE+author: rightfold+maintainer: rightfold@gmail.com+bug-reports: https://github.com/rightfold/open-browser/issues+category: Network+build-type: Simple+cabal-version: >=1.10++source-repository head+ type: git+ location: https://github.com/rightfold/open-browser.git++library+ exposed-modules: Network.Browser+ hs-source-dirs: lib+ default-language: Haskell2010+ build-depends: base >= 4 && < 5, process >= 1 && < 2++executable example+ main-is: Main.hs+ hs-source-dirs: example+ default-language: Haskell2010+ build-depends: base >= 4 && < 5, open-browser