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 6381211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:22:03+00:00 2026-05-25T02:22:03+00:00

Perhaps I’m going about this the wrong way, but I’m using HXT to read

  • 0

Perhaps I’m going about this the wrong way, but I’m using HXT to read in some vertex data that I’d like to use in an array in HOpenGL. Vertex arrays need to be a Ptr which is created by calling newArray. Unfortunately newArray returns an IO Ptr, so I’m not sure how to go about using it inside an Arrow. I think I need something with a type declaration similar to IO a -> Arrow a?

  • 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-25T02:22:03+00:00Added an answer on May 25, 2026 at 2:22 am

    The type IO a -> Arrow a doesn’t make sense; Arrow is a type class, not a specific type, much like Monad or Num. Specifically, an instance of Arrow is a type constructor taking two parameters that describes things that can be composed like functions, matching types end-to-end. So, converting IO a to an arrow could perhaps be called a conceptual type error.

    I’m not sure exactly what you’re trying to do, but if you really want to be using IO operations as part of an Arrow, you need your Arrow instance to include that. The simplest form of that is to observe that functions with types like a -> m b for any Monad instance can be composed in the obvious way. The hxt package seems to provide a more complicated type:

    newtype IOSLA s a b = IOSLA { runIOSLA :: s -> a -> IO (s, [b]) }
    

    This is some mixture of the IO, State, and [] monads, attached to a function as above such that you can compose them going through all three Monads at each step. I haven’t really used hxt much, but if these are the Arrows you’re working with, it’s pretty simple to lift an arbitrary IO function to serve as one–just pass the state value s through unchanged, and turn the output of the function into a singleton list. There may already be a function to do this for you, but I didn’t see one at a brief glance.

    Basically, you’d want something like this:

    liftArrIO :: (a -> IO b) -> IOSLA s a b
    liftArrIO f = IOSLA $ \s x -> fmap (\y -> (s, [y])) (f x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perhaps I'm going about this all wrong (and please tell me if I am),
Perhaps there is a better way to do this, but here's where I'm at
Perhaps this is mere wishful thinking, but is there a simple way (in ASP.NET)
Perhaps this is nitpicky, but I have to ask. I'm using Nokogiri to parse
Perhaps I'm using the OpenFileDialog incorrectly, but I've found that unhandled exceptions are being
Perhaps this is the wrong place for this, but I'm not quite sure where
Perhaps my brain is fried, but I'm writing a plugin that created an tweaks
Perhaps there's a better way to set this up so I'm open to suggestions.
Perhaps I'm using $.data incorrectly. Assigning the data: var course_li = sprintf('<li class=draggable course>%s</li>',
Perhaps I am missing something, but I can't explain this from any IE bug

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.