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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:44:41+00:00 2026-05-30T14:44:41+00:00

When I use fmap over a value, it essentially unboxes that value, applies the

  • 0

When I use fmap over a value, it essentially “unboxes” that value, applies the function to it, and boxes it back up.

For example:

-- returns Just 8
fmap (+3) (Just 5)

Is there any function that gives me the value without boxing it back up?

-- returns 8
fmap_2 (+3) (Just 5)

Granted, I don’t know how this would work for arrays, but it would be useful for Eithers and Maybes, for starters. I could also use it to mix Monads easily:

-- myfunc :: Maybe Int

-- if myfunc returned a Just, show it and then print it. Otherwise, print 'Nothing'.
putStrLn . fmap show $ myfunc

Or is there another standard way of mixing Monads?

  • 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-30T14:44:42+00:00Added an answer on May 30, 2026 at 2:44 pm

    For extracting Maybe use maybe:

    maybe 0 (+3) $ Just 5
    >>> 8
    maybe 0 (+3) Nothing
    >>> 0
    

    You should use fromJust only when getting a Nothing must be considered as an abnormal situation. Don’t evolve a habit of crashing your program without a really good reason to. The Maybe and Either are there exactly to help you avoid that.

    For Either there is a function either:

    either (*2) (+2) $ Left 3
    >>> 6
    either (*2) (+2) $ Right 3
    >>> 5
    

    Please note that in correct code you won’t need to extract monads often. That’s kinda whole point about them and Haskell has to offer all the tools you may need to work with monadic values as if they were extracted.

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

Sidebar

Related Questions

Flowcharting. This ancient old practice that's been in use for over 1000 years now,
use case example I have a servlet that is receiving login requests. If a
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: I've just entered insert mode, and typed some text. Now I want
We use a data acquisition card to take readings from a device that increases
Use case example: Client A comes to request sales information, enters their zip code
Use Eclipse Classic with ADT plugin. Tried to make project from existing example of
use strict; use Time::HiRes qw[gettimeofday tv_interval]; my $start_index = int(rand(50))+100;#this value is arbitrary for
Use default: <input type=radio name=restype value=resdef onfocus=document.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = true; checked=checked /><br
Use AES/Rijndael or any symmetric encryption. Encrypt the hidden value using itself as the

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.