Comments (2)
I want to keep native code as a last resort for expressiveness, and I think this can be expressed without massive issues in pure Elm.
For example, List.foldl
is implemented as a loop under the hood, so it seems that defining your stuff in terms of that would be no problem. To do foldr
maybe you want to use List.reverse
but we are talking about non-crazy costs here. Does that route seem plausible? If not, why not?
from package.elm-lang.org.
Although Range.foldl
could be expressed in terms of List.foldl
, it would require allocating an intermediary list. If you want to work with a large range, for example range 0 50000 |> foldl (+) 0
, that may be impractical.
But further, I had envisioned using this as a simple and safe looping mechanism for counted loops. As an example, several List API functions which currently require native code (for safety) could be expressed in terms of Range.foldl
:
drop : Int -> List a -> List a
drop n xs =
let drop1 _ xs' =
case xs' of
_::rest -> rest
_ -> []
in
0 `to` n |> Range.foldl drop1 xs
repeat : Int -> a -> List a
repeat n x =
let cons1 _ xs = x :: xs
in
0 `to` n |> Range.foldl cons1 []
I agree that we should be eliminating native code wherever possible (for all the reasons stated in elm-lang/core#130). In this case, I felt Range.foldl
would actually help move towards that goal.
from package.elm-lang.org.
Related Issues (20)
- Switch to self-hosting fonts HOT 1
- The website doesn't explain how to import a package HOT 3
- Site does not show contents on Firefox HOT 2
- Cannot publish a 0.18 package HOT 3
- Can't link to top of module documentation page HOT 1
- Unpublish special-elektronik/elm-autocomplete due to organisation name change HOT 2
- Code highlighting broken when starting with module
- add dark mode HOT 3
- Can't build the backend server with Cabal
- Add documentation on how to build the backend server
- Add a page that lists packages published by a single author HOT 1
- Namespace organization
- Add a maintainer page, listing all packages maintained/owned by someone HOT 2
- package.elm-lang.org uses expired DST Root X3 certificate HOT 5
- Deleted Package HAN-ASD-DT/priority-queue
- Promote jfmengels/elm-review in package search results for "elm-review"
- Request to support query parameter for search query
- how to build?
- Limit for docs.json too low HOT 1
- READMEs only supported as Markdown
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from package.elm-lang.org.