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?
Share
The type
IO a -> Arrow adoesn’t make sense;Arrowis a type class, not a specific type, much likeMonadorNum. Specifically, an instance ofArrowis a type constructor taking two parameters that describes things that can be composed like functions, matching types end-to-end. So, convertingIO ato 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
IOoperations as part of anArrow, you need yourArrowinstance to include that. The simplest form of that is to observe that functions with types likea -> m bfor anyMonadinstance can be composed in the obvious way. Thehxtpackage seems to provide a more complicated type: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 threeMonads at each step. I haven’t really usedhxtmuch, but if these are theArrows you’re working with, it’s pretty simple to lift an arbitraryIOfunction to serve as one–just pass the state valuesthrough 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: