Things that I learn about Haskell (and specifically front end web development with ReflexFRP) this week:
- Functional Reactive Programming (FRP) is based on recognizing events, behaviors, and dynamics. ReflexFRP’s quickref page shows you how the functions look like, where
tis the timeline of which events behaviors and dynamics happen. Of the other the 3, I’m still trying to sort out which is constant, which is reactive, and so on. - Reflex-Dom has a base unit so most of the functions require a ` return ()` to compile. The code basically says return an empty unit.. here are the main examples I’ve used this:
elClass "div" "box" return ()
elClass "button" "widget" text "Click me"- Variables are defined with
let x = "value"whereas monads require binding with the left arrow,x <- somefunction
let h = "Hello World"
x <- elClass "div" "stylename" text h - If your Aeson hookup returns
Nothing, double check the type definitions because variables may have been misspelled or needs to be a Maybe type (JSON can sometimes pass an empty string or null value. I blogged about this experience last year, but didn’t realize that misspelled variables names gives the same error! - In a do block of haskell code, you don’t have to explicitly define variable names for the last thing returned.
a <- elDiv "parent" do
x <- elDiv "child" return ()
y <- elDiv "child" return ()
combineDyne (\x y -> customFunction x y) x y
elDiv "parent"
dynText a Acknowledgments
Many thanks for the Haskell engineers of a local haskell shop, Obsidian Systems for leading the Haskell Workshop on web development and also being available and encouraging when I ask naively-based questions.