Skip to content

Commit

Permalink
Merge pull request #237 from zer0-star/fix-222
Browse files Browse the repository at this point in the history
Fix bugs of Jikka.RestrictedPython.Convert.ToCore
  • Loading branch information
kmyk authored Sep 23, 2021
2 parents 5c9b37f + d698755 commit b963de0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Jikka/RestrictedPython/Convert/ToCore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ runBuiltin builtin = do
xs <- replicateM (length ts) Y.genVarName'
let lam body = Y.Lam "go0" (Y.curryFunTy ts ret) (foldr (\(i, t) -> Y.Lam (xs !! i) (Y.ListTy t)) body (zip [0 ..] ts))
let len = Y.Min1' Y.IntTy (foldr (Y.Cons' Y.IntTy) (Y.Nil' Y.IntTy) (zipWith (\i t -> Y.Len' t (Y.Var (xs !! i))) [0 ..] ts))
let body = Y.Map' Y.IntTy ret (Y.Lam "i" Y.IntTy (Y.uncurryApp (Y.Var "go0") (map (Y.Var . (xs !!)) [0 .. length ts - 1]))) (Y.Range1' len)
let body = Y.Map' Y.IntTy ret (Y.Lam "i" Y.IntTy (Y.uncurryApp (Y.Var "go0") (zipWith (\i t -> Y.At' t (Y.Var (xs !! i)) (Y.Var "i")) [0 ..] ts))) (Y.Range1' len)
return $ lam body
X.BuiltinSorted t -> go1 Y.Sorted t
X.BuiltinReversed t -> go1 Y.Reversed t
X.BuiltinEnumerate t -> do
t <- runType t
let body = Y.Lam "i" Y.IntTy (Y.uncurryApp (Y.Tuple' [Y.IntTy, t]) [Y.Var "i", Y.At' t (Y.Var "xs") (Y.Var "i")])
return $ Y.Lam "xs" (Y.ListTy t) (Y.Map' (Y.ListTy t) (Y.ListTy (Y.TupleTy [Y.IntTy, t])) body (Y.Range1' (Y.Len' t (Y.Var "xs"))))
return $ Y.Lam "xs" (Y.ListTy t) (Y.Map' Y.IntTy (Y.TupleTy [Y.IntTy, t]) body (Y.Range1' (Y.Len' t (Y.Var "xs"))))
X.BuiltinFilter t -> go1 Y.Filter t
X.BuiltinZip ts -> do
ts <- mapM runType ts
xs <- replicateM (length ts) Y.genVarName'
let lam body = foldr (\(i, t) -> Y.Lam (xs !! i) (Y.ListTy t)) body (zip [0 ..] ts)
let len = Y.Min1' Y.IntTy (foldr (Y.Cons' Y.IntTy) (Y.Nil' Y.IntTy) (zipWith (\i t -> Y.Len' t (Y.Var (xs !! i))) [0 ..] ts))
let body = Y.Map' Y.IntTy (Y.TupleTy ts) (Y.Lam "i" Y.IntTy (Y.uncurryApp (Y.Tuple' ts) (map (Y.Var . (xs !!)) [0 .. length ts - 1]))) (Y.Range1' len)
let body = Y.Map' Y.IntTy (Y.TupleTy ts) (Y.Lam "i" Y.IntTy (Y.uncurryApp (Y.Tuple' ts) (zipWith (\i t -> Y.At' t (Y.Var (xs !! i)) (Y.Var "i")) [0 ..] ts))) (Y.Range1' len)
return $ lam body
X.BuiltinAll -> go0 Y.All
X.BuiltinAny -> go0 Y.Any
Expand Down

0 comments on commit b963de0

Please sign in to comment.