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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:52:45+00:00 2026-06-14T16:52:45+00:00

If I have the following two Kleisli arrows: stdoutProcessA :: Kleisli Maybe String (IO

  • 0

If I have the following two Kleisli arrows:

stdoutProcessA :: Kleisli Maybe String (IO String)
writeToFileA :: Kleisli Maybe (FilePath, String) (IO ())

I would like to be able to write someting like:

compile = proc src -> do
    output <- stdoutProcessA -< "..."
    writeToFileA -< ("...", output)
    ...

which of course doesn’t work, because String doesn’t match with IO String. On the other hand, it is possible to define both stdoutProcessA and writeToFileA to be of type Kleisli IO ..., but then I wouldn’t be able to compose them with arrows of type Kleisli Maybe ..., which I need for other things.

I am not very experienced with arrows yet, so I’m probably missing something obvious. How would one go about doing the above?

  • 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-14T16:52:46+00:00Added an answer on June 14, 2026 at 4:52 pm

    These arrows don’t make much sense to me:

    stdoutProcessA :: Kleisli Maybe String (IO String)
    writeToFileA :: Kleisli Maybe (FilePath, String) (IO ())
    

    They represent functions with result Maybe (IO a), when you probably meant IO (Maybe a). The latter type represents IO actions which may fail, while in the former the failure or success cannot depend on the IO at all.

    The correct way to combine IO and Maybe is to use the MaybeT monad transformer, like so:

    stdoutProcessA :: Kleisli (MaybeT IO) String String
    writeToFileA :: Kleisli (MaybeT IO) (FilePath, String) ()
    

    If you write your other arrows as Monad m => Kleisli (MaybeT m) a b, they should compose nicely with these ones without any lifting. Alternatively, you can use

    lift' :: Monad m => Kleisli Maybe a b -> Kleisli (MaybeT m) a b
    lift' (Kleisli f) = Kleisli $ \x -> MaybeT (return $ f x)
    

    to lift your existing Kleisli Maybe arrows to Kleisli (MaybeT IO) where needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two javascript functions: 1 showCountry() 2 showUser() I would like
I have following two methods in my backing bean - public String validateUser() {
I have following two simple POJOs: class Person { String name Address address; //and
Let's suppose I have following two variables: arg1=5 count5=test Now, I want to able
I have the following two tables. I'd like colgroups for each to highlite with
I have the following two strings: $str='http://website.com/abc/?var=abc'; $str='http://website.com/abc/?xvar=123&var=xyz'; I would like to change $str
I have following two arrays. I want the difference between these two arrays. That
How to wrap one div around another? I have following two div ids: #course
I have the following two chunks of code, I am not so sure what
I have the following two tables in my mysql database. Table Name: groups id

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.