Questions tagged [purescript-halogen]

Use for questions regarding purescript-halogen, a UI library for [purescript]

purescript-halogen is a declarative, type-safe UI library for . It's roughly -like but distinguishes itself by including the component as a basic building block.

Resources

12 questions
3
votes
1 answer

Get keyboard event in purescript

I want to get keydown event in purescript so I used DomEvent. Here is my code. main :: Eff (HA.HalogenEffects (console :: CONSOLE, timer :: T.TIMER)) Unit main = HA.runHalogenAff do body <- HA.awaitBody cube <- runUI C.cubes unit body …
hamza mah
  • 41
  • 3
2
votes
1 answer

Can someone explain how the cofree comonad is "similar to" Halogen?

In the paper Declarative UIs are the future -- and the future is comonadic by Phil Friedman, he makes the claim, when introducing the cofree comonad that: ...this approach is reminiscent of the approach taken in the Halogen user interface…
Nathan BeDell
  • 2,263
  • 1
  • 14
  • 25
2
votes
1 answer

How to make focus components composable in Halogen

Playing with a simple demo app in Halogen with a dynamic list filled with values from an input field, I realized, that returning focus back to input after button click, is pretty hard. There is just 1 way: define FFI method which discovers element…
Daniil Iaitskov
  • 5,525
  • 8
  • 39
  • 49
2
votes
1 answer

How to use logShow inside the handleAction function in Halogen 5

As the title says, I am trying to use logShow inside of my handleAction function. I imported the Effect.Console (logShow) and tried to use it like this, everytime a button is clicked: handleAction ∷ forall o m. Action → H.HalogenM State Action () o…
2
votes
1 answer

How to implement something like an autoincrement counter in Purescript Halogen

Given a really simple increment component in something like React: class Increment extends React.Component { constructor(props){ super(props) this.state = { value: props.value } } componentDidMount() { setInterval(() =>…
danbroooks
  • 2,712
  • 5
  • 21
  • 43
2
votes
1 answer

How to define an eval function with an empty query type?

I have a query type data Query a Given that Query has no constructors, how can I define an eval function of type: eval :: Query ~> H.ComponentDSL State Query Void m Would I have to add a constructor to Query?
whbb
  • 520
  • 5
  • 13
1
vote
1 answer

purescript halogen - render elements or nothing conditionally

I have a utility function to conditinally render elements: thanRender :: ∀ w i. Boolean -> EL.HTML w i -> EL.HTML w i thanRender true h = h thanRender _ _ = EL.text "" Usage: isJust state.foo `thanRender` (EL.h1_ [ EL.text state.title ]) Is…
1
vote
1 answer

How to chain actions in purescript (or maybe defer action after rendering)

I'm learning Halogen at the moment but I have a hard time finding how to chain actions. Let's say I have a simple article list component. I also have an "add" button to create a new article to be edited in place in the list. My approach would be to…
amaille
  • 55
  • 7
0
votes
0 answers

purescript: change element inside SVG

I have a SVG image like the following: It is a simple SVG with a number in it. The SVG file looks something like this: 6 ... I…
cdupont
  • 1,138
  • 10
  • 17
0
votes
1 answer

Purescript compiles but js throws error : component.initialState is not a function

I'm building a simple video player component using purescript-halogen. The component is supposed to show a blank div with only an input button for the user to select a local file which will then act as a source URL for the video element. I completed…
0
votes
1 answer

How do you access highlighted text in Purescript?

I'm creating an application in Purescript and I want to have a text box displaying some documentation, and then I want to perform some NLP tasks on the server based on the sentences highlighted by the mouse on that text. How could I extract that…
tonicebrian
  • 4,715
  • 5
  • 41
  • 65
0
votes
1 answer

Getting "An infinite type was inferred for an expression" for query'/request from Halogen

In my component: data Query a = SetImageUrl Int String a Main (app) component: eval :: Query ~> H.ParentDSL State Query ChildQuery ChildSlot Void m eval = case _ of HandleItemChange groupId (LIS.ActiveChanged selected) next -> do let…
menfon
  • 1,587
  • 1
  • 11
  • 28