@@ -28,6 +28,7 @@ module Angular.NgModelController
2828 ) where
2929
3030import Control.Monad.Eff
31+ import Data.Function
3132import Data.Maybe
3233
3334foreign import data NgModelController :: * -> *
@@ -129,39 +130,47 @@ foreign import setModelValue
129130 \ } "
130131 :: forall e a b . b -> NgModelController a -> Eff (ngmodel :: NgModelCtrl | e ) (NgModelController b )
131132
132- foreign import appendParsers
133- " function appendParsers(parsers){ \
134- \ return function($ctrl){ \
135- \ return function(){ \
136- \ var as = []; \
137- \ angular.forEach(parsers, function(p){ \
138- \ as.push(function(v){ \
139- \ return p(v).values[0]; \
140- \ }); \
133+ foreign import appendParsersFn
134+ " function appendParsersFn(fromMaybe, parsers, $ctrl){ \
135+ \ return function(){ \
136+ \ var as = []; \
137+ \ angular.forEach(parsers, function(p){ \
138+ \ as.push(function(v){ \
139+ \ return fromMaybe(undefined)(p(v)); \
141140 \ }); \
142- \ $ctrl.$parsers.push.apply($ctrl.$parsers, as ); \
143- \ return {} ; \
144- \ }; \
141+ \ } ); \
142+ \ $ctrl.$parsers.push.apply($ctrl.$parsers, as) ; \
143+ \ return { }; \
145144 \ }; \
146145 \ } "
147- :: forall e a . [Parser a ] -> NgModelController a -> Eff (ngmodel :: NgModelCtrl | e ) Unit
146+ :: forall e a . Fn3 (a -> Maybe a -> a )
147+ [Parser a ]
148+ (NgModelController a )
149+ (Eff (ngmodel :: NgModelCtrl | e ) Unit )
148150
149- foreign import prependParsers
150- " function prependParsers(parsers){ \
151- \ return function($ctrl){ \
152- \ return function(){ \
153- \ var as = []; \
154- \ angular.forEach(parsers, function(p){ \
155- \ as.push(function(v){ \
156- \ return p(v).values[0]; \
157- \ }); \
151+ appendParsers :: forall e a . [Parser a ] -> NgModelController a -> Eff (ngmodel :: NgModelCtrl | e ) Unit
152+ appendParsers = runFn3 appendParsersFn fromMaybe
153+
154+ foreign import prependParsersFn
155+ " function prependParsersFn(fromMaybe, parsers, $ctrl){ \
156+ \ return function(){ \
157+ \ var as = []; \
158+ \ angular.forEach(parsers, function(p){ \
159+ \ as.push(function(v){ \
160+ \ return fromMaybe(undefined)(p(v)); \
158161 \ }); \
159- \ $ctrl.$parsers.unshift.apply($ctrl.$parsers, as ); \
160- \ return {} ; \
161- \ }; \
162+ \ } ); \
163+ \ $ctrl.$parsers.unshift.apply($ctrl.$parsers, as) ; \
164+ \ return { }; \
162165 \ }; \
163166 \ } "
164- :: forall e a . [Parser a ] -> NgModelController a -> Eff (ngmodel :: NgModelCtrl | e ) Unit
167+ :: forall e a . Fn3 (a -> Maybe a -> a )
168+ [Parser a ]
169+ (NgModelController a )
170+ (Eff (ngmodel :: NgModelCtrl | e ) Unit )
171+
172+ prependParsers :: forall e a . [Parser a ] -> NgModelController a -> Eff (ngmodel :: NgModelCtrl | e ) Unit
173+ prependParsers = runFn3 prependParsersFn fromMaybe
165174
166175foreign import appendFormatters
167176 " function appendFormatters(formatters){ \
0 commit comments