AccelerateHS / AccelerateHS/accelerate

Support recursive functions

Open
#346 4 comments 0 reactions 0 assignees View on GitHub
language new feature
Dominant language
Haskell
Stars
1k
Forks
135
PR merge metrics
No merged PRs in 30d

Description

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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.