AccelerateHS / AccelerateHS/accelerate

Support recursive functions

未关闭
#346 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
language new feature
主要语言
Haskell
星标
1k
派生
135
PR 合并指标
30 天内没有已合并 PR

描述

Would it be feasible to add a combinator that looks like this?

```
ewhile :: (Elt a, Elt b) => (Exp a -> Exp (Either b a)) -> Exp a -> Exp b
```

It would iteratively feed the values of type `a` back into the function, until it gets a `Left` value. Once it gets a `Left` value, it would stop.

I started trying to add it myself, but I got stuck when it looked like I needed to implement an `Elt` instance for `Either`. It seems like, in theory, this shouldn't require an `Elt` instance because the `Either` can only ever be used for determining control flow in one particular combinator so an actual representation of the `Either` would never really be needed.

The use case is that I am working on a translation system that converts (more-or-less) normal Haskell code to Haskell code that uses Accelerate. At the moment, it seems like it would be significantly easier to convert general tail recursive functions into a call to something like `ewhile` than it would to the existing `while`.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。