Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 802441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:36:10+00:00 2026-05-14T23:36:10+00:00

Could someone explain me what this code does line by line ? how t

  • 0

Could someone explain me what this code does line by line ?

how t ounderstand excactly first line with declaration ?
what does it mean: [Prop (Grid ())]?

thanks for help

gridCtrl :: Window a -> [Prop (Grid ())] -> IO (Grid ())
gridCtrl parent props
  = feed2 props 0 $
    initialWindow $ \id rect -> \props flags ->
    do g <- gridCreate parent id rect flags
       gridCreateGrid g 0 0 0
       set g props
       return g
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:36:11+00:00Added an answer on May 14, 2026 at 11:36 pm

    In wxHaskell, controls have attached properties which can be read or changed. The stanza [Prop (Grid ())] can be understood as “a list of properties for any Grid type”.

    This is wxHaskell’s way of dealing with the fact that the wxWidgets library, which it is built on, is object-oriented. Grid () actually means “anything in the inheritance hierarchy from which Grid derives” – i.e. Grid, ScrolledWindow, Panel, Window, EvtHandler, wxObject (you can follow this through if you start at at http://wxhaskell.sourceforge.net/doc/Graphics-UI-WXCore-WxcClassTypes.html#204)

    When you look at the documentation of a Control (e.g. ListCtrl) you will find that it is reported as having a set of Attributes and Instances. Basically, you can use those which apply to the hierarchy for Grid. For example, Grid derives from ScrolledWindow, so you can use:

    • Attribute scrollRate
    • Attributes of Colored class e.g. bgcolor, color
    • etc.

    You use these properties as follows, e.g.

    g <- gridCtrl parent [color := red, bgcolor := green, scrollRate := 41]
    ...
    set g [color := blue]
    

    Line by line, the code reads something like the following:

    • Using the supplied properties (props)
    • and an initialWindow (which will fill in the window id and initial rect and flags), call the floowing wrapped functions in order:
    • gridCreate to create a new Grid instance
    • Using the new grid instance, set the grid inside with 0 rows, 0 columns and nothing selected.
    • Apply the properties (props) supplied by the caller to the grid (e.g. put data in, set styles etc.)

    The part which makes the code hardest to read is the feed2 function, and that fact that the code is written in ‘$’ style to provide the correct parameters to feed2. My slightly hand-waving explanation above should be enough, but if you want to understand the details, understand that feed2 is just composed inverted function application

    feed2 x y f = f x y
    

    then replace the ‘$’ applications with parentheses. This doesn’t look as cute, but is easier to read.

    gridCtrl parent props =
      feed2 props 0
        (initialWindow (\id rect ->
                          \props flags ->
                            do
                            g <- gridCreate parent id rect flags
                            gridCreateGrid g 0 0 0
                            set g props
                            return g )))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone explain what this code does size = *(int *)data; // size of
Could someone please explain what this does and how it is legal C code?
Could someone explain to me what this portion of code means? repeat scroll 0
Could someone explain this (strange) behavior? Why is the length in the first example
Could someone explain in layman terms what this actually does? XmlTextReader textReader = new
Please could someone explain to me why this regex does not match anything, when
Could someone help me explain this? I have two snippets of code, one works
Can someone please explain what does the following line of code exactly do? If
I was wondering if someone could explain to me what the line of code
Could someone please explain to me whats wrong with this code? #include<stdio.h> struct A{

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.