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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:12:13+00:00 2026-05-20T21:12:13+00:00

I have one function first with type: Int -> [a] -> (Error ([a],[a])) and

  • 0

I have one function first with type: Int -> [a] -> (Error ([a],[a])) and a second function second with type: [a] -> [a] -> [a]

I am trying to make a third function now that uses the above functions.
the type I have for this function is: [Int] -> [a] -> Error [a]

I have been given these types to work around so cant change them.

This is what I tried:

last :: [Int] -> [a] -> Error [a]
last (x:xs) list = second (first x list)

Can you pass outputs from functions that use the error function in to others?

  • 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-20T21:12:14+00:00Added an answer on May 20, 2026 at 9:12 pm

    Assuming Error is an error monad, you can use the monadic bind operator (>>=) and the uncurry function:

    z (x:xs) list = F x list >>= return . uncurry Q
    

    uncurry transforms Q from a function with two arguments (aka a curried function) into a function on pairs. This means that uncurry Q :: ([a], [a]) -> [a]

    The bind operator takes a value out of a monad and passes it into a monadic function. Here we’re extracting the value of the Error monad returned by F and passing it to Q, now turned into a monadic function that works on a pair of lists, thanks to return and uncurry.

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

Sidebar

Related Questions

I have a simple question related to one-line programming. First an example: function test(a)
I am developing a C# program, and i have one function that consumes too
Ok, I have one JavaScript that creates rows in a table like this: function
I have a function that resembles the one below. I'm not sure how to
I have a function that accepts a char* as one of its parameters. I
I have a javascript function (class) that takes a function reference as one paremter.
Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
I have a function which parses one string into two strings. In C# I
Imagine I have an function which goes through one million/billion strings and checks smth
I have a web project that I developed where one of the main functions

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.