funkia / purescript-turbine Goto Github PK
View Code? Open in Web Editor NEWPurely functional UI library powered by FRP.
License: MIT License
Purely functional UI library powered by FRP.
License: MIT License
The zip code example doesn't compile. It needs to be updated to the latest version of its dependencies.
Hello!
Please see the following example:
module Main where
import Prelude
import Data.FunctorWithIndex (mapWithIndex)
import Data.String as String
import Data.Tuple (Tuple(..))
import Data.Tuple as Tuple
import Effect (Effect)
import Turbine ((</>))
import Turbine as T
import Turbine.HTML as TH
-- | The entry-point application component, whose primary function it is to switch around
-- | between the login / registration / main activities.
app :: T.Component {} {}
app = T.component \o -> do
let
splitify :: String -> Array (Tuple Int String)
splitify s = mapWithIndex (\i c -> Tuple i (String.singleton c)) (String.toCodePointArray s)
(
(TH.input {} `T.use` (\oo -> {the_string: oo.value}))
</>
(TH.ul {} (T.list (show >>> TH.text >>> TH.li {}) (splitify <$> o.the_string) Tuple.fst))
) `T.output` {}
main :: Effect Unit
main = T.runComponent "#mount" app
Once loaded, try typing in the text field, then editing the typed string. Notice how the list not a proper function of the input behavior.
The current signature of list
(especially given the getKey
parameter) would suggest that the individual components are updated as the list changes, but this currently only happens when the key itself changes. Especially to newcomers to FRP (like me), this is very confusing.
Proposed solution: Add a new function that provides a Behavior a
instead of a a
to the coponent generator function.
Didn't notice this when testing (bower must not actually be installing from the local directory), but now that the version number has been updated, the examples are now broken again. Probably caused by moving all the types in Elements.purs from o
to Output
. For example, here is the error from the todomvc:
Error found:
in module Main
at src/Main.purs line 121, column 3 - line 130, column 4
Could not match type
( blur :: Stream FocusEvent
, click :: Stream Unit
, dblclick :: Stream Unit
, keydown :: Stream KeyboardEvent
, keyup :: Stream KeyboardEvent
)
with type
( addItem :: Stream String
, items :: Behavior
(Array
{ isComplete :: Behavior Boolean
, name :: Behavior String
, isEditing :: Behavior Boolean
, delete :: Stream Int
}
)
)
while trying to match type { click :: Stream Unit
, dblclick :: Stream Unit
, keydown :: Stream KeyboardEvent
, keyup :: Stream KeyboardEvent
, blur :: Stream FocusEvent
}
with type { addItem :: Stream String
, items :: Behavior
(Array
{ isComplete :: Behavior Boolean
, name :: Behavior String
, isEditing :: Behavior Boolean
, delete :: Stream Int
}
)
}
while checking that expression (section { "class": ...
}
)
((header { "class": ...
}
)
((merge (...)) (todoFooter { todos: ...
}
)
)
)
has type Component
{ addItem :: Stream String
, items :: Behavior
(Array
{ isComplete :: Behavior Boolean
, name :: Behavior String
, isEditing :: Behavior Boolean
, delete :: Stream Int
}
)
}
{ addItem :: Stream String
, items :: Behavior
(Array
{ isComplete :: Behavior Boolean
, name :: Behavior String
, isEditing :: Behavior Boolean
, delete :: Stream Int
}
)
}
in value declaration todoAppView
I'm currently evaluating a number of FRP-based purescript libraries but couldn't install purescript-turbine
using psc-package
which is, in my experience, way better than bower
.
purescript-hareactive
and purescript-turbine
both do not exist in psc-package
's package set. Will you consider adding psc-package
support for both of these libraries?
BTW, from reading the README(s) (including JS/TS libraries), the maintainers've done an excellent job. Hope support does not die away like with many other similar libraries.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.