on master help sign in
Restrict list interpolation to numbers!
dd1b3d4Evan Czaplicki
compiler/Type/Constrain/Expression.hs+4−4
@@ -36,10 +36,10 @@ constrain env (A region expr) tipe =
36 | otherwise -> return (name <? tipe)
36 | otherwise -> return (name <? tipe)
37
37
38 Range lo hi ->
38 Range lo hi ->
39− exists $ \x -> do
39+ existsNumber $ \n -> do
40− clo <- constrain env lo x
40+ clo <- constrain env lo n
41− chi <- constrain env hi x
41+ chi <- constrain env hi n
42− return $ and [clo, chi, list x === tipe]
42+ return $ and [clo, chi, list n === tipe]
43
43
44 ExplicitList exprs ->
44 ExplicitList exprs ->
45 exists $ \x -> do
45 exists $ \x -> do
compiler/Type/Type.hs+5
@@ -141,6 +141,11 @@ exists f = do
141 v <- liftIO $ var Flexible
141 v <- liftIO $ var Flexible
142 ex [v] <$> f (VarN v)
142 ex [v] <$> f (VarN v)
143
143
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+
144
149
145instance Show a => Show (UF.Point a) where
150instance Show a => Show (UF.Point a) where
146 show point = unsafePerformIO $ fmap show (UF.descriptor point)
151 show point = unsafePerformIO $ fmap show (UF.descriptor point)