Comments (2)
Sorry for the delay on this! The 0.12 release from yesterday revamps this API and implementation, so I have been slow to respond on bugs I knew were going to "go away".
Here's how the new API works. Please let us know if there are still issues!
from elm-lang.org.
Thanks! It took a little thinking to rewrite it to use the new API, but I can see how it's nicer; and the bug is fixed now. Updated code, if you're interested:
import Graphics.Input (input, button)
import Graphics.Input.Field (field, Content, noContent, defaultStyle)
-- Some utilities
mapi : (Int -> a -> b) -> [a] -> [b]
mapi f l = zipWith f [0 .. length l - 1] l
replaceAt : Int -> a -> [a] -> [a]
replaceAt i a l =
case l of [] -> []
x::xs -> if i == 0 then a :: xs
else x :: replaceAt (i-1) a xs
-- Main program
data Event = Nop | Create | Change Int Content
events = input Nop
makeButton = button events.handle
makeField = field defaultStyle events.handle
type State = [Content]
btnCreate = makeButton Create "Create"
view : State -> Element
view lst =
let viewOne idx content =
makeField (Change idx) "Write here!" content
`above`
plainText content.string
in flow down (btnCreate :: mapi viewOne lst)
update : Event -> State -> State
update evt x =
case evt of
Nop -> x
Create -> x ++ [noContent]
Change i c -> replaceAt i c x
main = view <~ foldp update [] events.signal
from elm-lang.org.
Related Issues (20)
- ASCII codes are seven bit HOT 1
- google search preview of the site is a little bit scary for new visitors
- delete account on discourse? HOT 2
- Add permalink feature in Try Elm
- Elm executable package is considered to be 'Dangerous' by Windows Smart Screen
- SEO meta description tag HOT 1
- Hover causing layout changes HOT 3
- links to examples on the A Farewell to FRP page are broken
- The landing page is quite user hostile HOT 6
- New playground design feedback
- Inaccuracy: Elm does not enforce semantic versioning
- Main page logo effects competely broken in Firefox HOT 10
- Cat-gifs not showing gifs of cats
- Blank website when JavaScript disabled
- font color issues on elm-lang.org/docs/syntax with chrome based browsers on MacOS
- Out-of-the-box experience.
- None of the default Elm examples show how to use CSS or give any CSS-related advice
- Type question on form.html HOT 1
- Explain `import` early on guide.elm-lang.org
- Add "How to uninstall elm" section HOT 1
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 elm-lang.org.