on master help sign in
Restrict list interpolation to numbers!
commitdd1b3d4d7c8dd7bbffd2e1f5c20c4d018b55ba74 authorEvan Czaplicki <info@elm-lang.org> dateFri 21 Feb 2014, 16:21 (13 years ago) parentfea6361
2 files changed+9−4
compiler/Type/Constrain/Expression.hs+4−4 compiler/Type/Type.hs+5
compiler/Type/Constrain/Expression.hs+4−4
@@ -36,10 +36,10 @@ constrain env (A region expr) tipe =
3636 | otherwise -> return (name <? tipe)
3737
3838 Range lo hi ->
39− exists $ \x -> do
40− clo <- constrain env lo x
41− chi <- constrain env hi x
42− return $ and [clo, chi, list x === tipe]
39+ existsNumber $ \n -> do
40+ clo <- constrain env lo n
41+ chi <- constrain env hi n
42+ return $ and [clo, chi, list n === tipe]
4343
4444 ExplicitList exprs ->
4545 exists $ \x -> do
compiler/Type/Type.hs+5
@@ -141,6 +141,11 @@ exists f = do
141141 v <- liftIO $ var Flexible
142142 ex [v] <$> f (VarN v)
143143
144+existsNumber :: Error e => (Type -> ErrorT e IO TypeConstraint) -> ErrorT e IO TypeConstraint
145+existsNumber f = do
146+ v <- liftIO $ var (Is Number)
147+ ex [v] <$> f (VarN v)
148+
144149
145150instance Show a => Show (UF.Point a) where
146151 show point = unsafePerformIO $ fmap show (UF.descriptor point)