diff options
author | eric thul <thul.eric@gmail.com> | 2015-08-11 20:57:07 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2015-08-11 20:57:07 -0400 |
commit | 03b840cb5fb8ff5217fefc9e1240a3131db309fc (patch) | |
tree | 6183f4453aa15ad67ee0249fb8d35702cef5ecad /src/PursLoader/Options.purs | |
parent | fa01c5a4cb42d80ac147dc5ab512a0795dbe14da (diff) | |
download | purs-loader-03b840cb5fb8ff5217fefc9e1240a3131db309fc.tar.gz purs-loader-03b840cb5fb8ff5217fefc9e1240a3131db309fc.tar.zst purs-loader-03b840cb5fb8ff5217fefc9e1240a3131db309fc.zip |
PureScript 0.7 updates and migration to pulp
Diffstat (limited to 'src/PursLoader/Options.purs')
-rw-r--r-- | src/PursLoader/Options.purs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/PursLoader/Options.purs b/src/PursLoader/Options.purs index 51e9be5..e3957eb 100644 --- a/src/PursLoader/Options.purs +++ b/src/PursLoader/Options.purs | |||
@@ -4,6 +4,8 @@ module PursLoader.Options | |||
4 | , loaderFFIOption | 4 | , loaderFFIOption |
5 | ) where | 5 | ) where |
6 | 6 | ||
7 | import Prelude (Unit(), (<>), (<$>), (<<<), (++), (<*>), const) | ||
8 | |||
7 | import Data.Array (concat) | 9 | import Data.Array (concat) |
8 | import Data.Either (either) | 10 | import Data.Either (either) |
9 | 11 | ||
@@ -45,8 +47,8 @@ newtype Options | |||
45 | , output :: NullOrUndefined String | 47 | , output :: NullOrUndefined String |
46 | , noPrefix :: NullOrUndefined Boolean | 48 | , noPrefix :: NullOrUndefined Boolean |
47 | , requirePath :: NullOrUndefined String | 49 | , requirePath :: NullOrUndefined String |
48 | , src :: NullOrUndefined [String] | 50 | , src :: NullOrUndefined (Array String) |
49 | , ffi :: NullOrUndefined [String] | 51 | , ffi :: NullOrUndefined (Array String) |
50 | } | 52 | } |
51 | 53 | ||
52 | instance isForeignOptions :: IsForeign Options where | 54 | instance isForeignOptions :: IsForeign Options where |
@@ -74,7 +76,7 @@ instance isForeignOptions :: IsForeign Options where | |||
74 | <*> readProp ffiOpt obj) | 76 | <*> readProp ffiOpt obj) |
75 | 77 | ||
76 | class LoaderOption a where | 78 | class LoaderOption a where |
77 | opt :: String -> NullOrUndefined a -> [String] | 79 | opt :: String -> NullOrUndefined a -> Array String |
78 | 80 | ||
79 | instance booleanLoaderOption :: LoaderOption Boolean where | 81 | instance booleanLoaderOption :: LoaderOption Boolean where |
80 | opt key val = maybe [] (\a -> if a then ["--" ++ key] else []) (runNullOrUndefined val) | 82 | opt key val = maybe [] (\a -> if a then ["--" ++ key] else []) (runNullOrUndefined val) |
@@ -82,11 +84,11 @@ instance booleanLoaderOption :: LoaderOption Boolean where | |||
82 | instance stringLoaderOption :: LoaderOption String where | 84 | instance stringLoaderOption :: LoaderOption String where |
83 | opt key val = maybe [] (\a -> ["--" ++ key ++ "=" ++ a]) (runNullOrUndefined val) | 85 | opt key val = maybe [] (\a -> ["--" ++ key ++ "=" ++ a]) (runNullOrUndefined val) |
84 | 86 | ||
85 | instance arrayLoaderOption :: (LoaderOption a) => LoaderOption [a] where | 87 | instance arrayLoaderOption :: (LoaderOption a) => LoaderOption (Array a) where |
86 | opt key val = concat (opt key <$> (NullOrUndefined <<< Just) | 88 | opt key val = concat (opt key <$> (NullOrUndefined <<< Just) |
87 | <$> (fromMaybe [] (runNullOrUndefined val))) | 89 | <$> (fromMaybe [] (runNullOrUndefined val))) |
88 | 90 | ||
89 | pscOptions :: Foreign -> [String] | 91 | pscOptions :: Foreign -> Array String |
90 | pscOptions query = either (const []) fold parsed | 92 | pscOptions query = either (const []) fold parsed |
91 | where parsed = read query :: F Options | 93 | where parsed = read query :: F Options |
92 | fold (Options a) = opt noPreludeOpt a.noPrelude <> | 94 | fold (Options a) = opt noPreludeOpt a.noPrelude <> |
@@ -100,8 +102,8 @@ pscOptions query = either (const []) fold parsed | |||
100 | opt requirePathOpt a.requirePath <> | 102 | opt requirePathOpt a.requirePath <> |
101 | opt ffiOpt a.ffi | 103 | opt ffiOpt a.ffi |
102 | 104 | ||
103 | loaderSrcOption :: Foreign -> Maybe [String] | 105 | loaderSrcOption :: Foreign -> Maybe (Array String) |
104 | loaderSrcOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.src) (read query) | 106 | loaderSrcOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.src) (read query) |
105 | 107 | ||
106 | loaderFFIOption :: Foreign -> Maybe [String] | 108 | loaderFFIOption :: Foreign -> Maybe (Array String) |
107 | loaderFFIOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.ffi) (read query) | 109 | loaderFFIOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.ffi) (read query) |