简体   繁体   中英

How to have procedural radioField options in haskells brick library

I can't wrap my head around how to have procedural a radioField , since I have to give each option a name. In my case, I want to load the available options from a database and therefore I can't have them statically named. Has anybody an idea?

radioField handed [ (LeftHanded, LeftHandField, "Left")
                  , (RightHanded, RightHandField, "Right")
                  , (Ambidextrous, AmbiField, "Both")
                  ]

I'm the author of Brick. For what it's worth, the Brick Users e-mail list is a good place to ask questions like this.

To your question, though: since the name type is under your control, you can give your name type a constructor that takes parameters to construct sufficiently unique name values that are relevant to the data for each radio button value. For example, if you load database data and each value of your radio button is associated with some numeric ID, you might just have a name type like:

-- The type of database record IDs
type ID = Int

data Name = ...
          | RadioOption ID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM