{-# LANGUAGE CPP #-}
module Web.Browser
( openBrowser
) where
#if defined(mingw32_HOST_OS)
import Web.Browser.Windows (openBrowserWindows)
#else
import Data.List (isInfixOf)
import System.Info (os)
import Web.Browser.Linux (openBrowserLinux)
import Web.Browser.OSX (openBrowserOSX)
#endif
openBrowser :: String -> IO Bool
#if defined(mingw32_HOST_OS)
openBrowser = openBrowserWindows
#else
openBrowser :: String -> IO Bool
openBrowser
| (String -> Bool) -> [String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isInfixOf` String
os) [String
"linux", String
"bsd"] = String -> IO Bool
openBrowserLinux
| String
"darwin" String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isInfixOf` String
os = String -> IO Bool
openBrowserOSX
| Bool
otherwise = String -> String -> IO Bool
forall a. HasCallStack => String -> a
error String
"unsupported platform"
#endif