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

  • Home
  • SEARCH
  • 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 8324471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:05:08+00:00 2026-06-09T00:05:08+00:00

I have a binding for a type [ST s (Int, [Int])] and I am

  • 0

I have a binding for a type [ST s (Int, [Int])] and I am trying to apply runST to each element using map as follows:

name :: [ST s (Int, [Int])] --Of Course there is a real value here
map runST name

This gives me an error message

Couldn't match expected type `forall s. ST s b0'
    with actual type `ST s0 (Int, [Int])'
Expected type: [forall s. ST s b0]
  Actual type: [ST s0 (Int, [Int])]
In the second argument of `map', namely `name'
In the expression: map runST name

There must be something I am misunderstanding. I am aware of runST and function composition, but am unsure if this applies.

Thanks for everyones time!

  • 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-06-09T00:05:09+00:00Added an answer on June 9, 2026 at 12:05 am

    Each time you run a state transformer with runST, it operates on some local state that is separate from all other state transformers. runST creates a new state type and calls its argument with that type. So, for example, if you execute

    let x = runST (return ())
        y = runST (return ())
    in (x, y)
    

    then the first return () and second return () will have different types: ST s1 () and ST s2 (), for some unknown types s1 and s2 that are created by runST.

    You are trying to call runST with an argument that has state type s. That is not the state type that runST creates, nor is any other type you can choose. To call runST, you must pass an argument that can have any state type. Here is an example:

    r1 :: forall s. ST s ()
    r1 = return ()
    

    Because r1 is polymorphic, its state can have any type, including whatever type is selected by runST. You can map runST over a list of polymorphic r1s (with -XImpredicativeTypes):

    map runST ([r1, r1] :: [forall t. ST t ()])
    

    However, you cannot map runST over a list of non-polymorphic r1s.

    map runST ([r1, r1] :: forall t. [ST t ()]) -- Not polymorphic enough
    

    The type forall t. [ST t ()] says that all list elements have state type t. But they need to all have independent state types because runST is called on each one. That is what the error message means.

    If it is okay to give the same state to all list elements, then you can call runST once as shown below. The explicit type signature is not required.

    runST (sequence ([r1, r1] :: forall t. [ST t ()]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an custom binding defined as follows: <customBinding> <binding name=binaryHttpBinding> <binaryMessageEncoding /> <httpTransport
I have a ComboBox whose xaml is as follows <ComboBox Name=ComboBoxDiscussionType IsEnabled={Binding ElementName=ComboBoxDiscussionType, Path=Items.Count,
I have a treeview with checkboxes for each item using a DataTemplate. <TreeView ItemsSource={Binding}>
I have the following code currently: <DataTemplate DataType={x:Type vm:SectionViewModel}> <ScrollViewer> <ItemsControl ItemsSource={Binding ViewModels}> </ItemsControl>
I have the following XAML: <ListBox HorizontalAlignment=Left Margin=0,6,0,10 Name=listBox1 Width=468 ItemsSource={Binding} Grid.ColumnSpan=1> <ItemsControl.ItemTemplate> <DataTemplate>
I have the following C# code: int CallFooMethod() { Type type = TypeDelegator.GetTypeFromProgID(SomeCOMDll.SomeCOMClass); dynamic
I have a WPF Datagrid populated using a Dataset. I am trying to change
I have text field that binding with int property ProductPrice and button that is
I have a popup with a listview inside: <Popup Name=PopupResultados Width=200 PlacementTarget={Binding ElementName=textBoxBuscar} AllowsTransparency=True
There is a raw socket type provided in Network.Socket, but near binding sockets there

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.