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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:51:15+00:00 2026-05-24T23:51:15+00:00

I am learning Haskell and want to use readHex, which according to Hoogle has

  • 0

I am learning Haskell and want to use “readHex”, which according to Hoogle has type:

readHex :: Num a => ReadS a

How do you “extract” a result from such a function? What’s the most common way, pattern match against the right constructor ie, [(a,””)] ??

LiftM and lifting in general seems to make some sense, but I’m lost when it comes to “unwinding” the monadic stack.

  • 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-24T23:51:16+00:00Added an answer on May 24, 2026 at 11:51 pm

    To answer the general question in general terms, the only way to extract values from a data constructor is pattern matching. Some data types come with functions that extract values for you, but those functions are themselves implemented with pattern matching, or call other functions that are, &c. Abstract data types like Data.Map.Map or IO, that want to hide their internal structure, still require pattern matching to work with; the difference is that they don’t export their constructors from the module that defines them, so all you have to work with are other functions defined in the module and the operations they provide.

    To answer the specific question, ReadS is defined as such:

    type ReadS a = String -> [(a, String)]
    

    So it’s just a type synonym. You don’t need to extract anything from the ReadS itself, it’s just a shorthand or alias. The actual type is [(a, String)], which you can work with the same way you would anything else using lists, tuples, Strings, and so on.

    Furthermore, ReadS is not a Monad. It’s a type synonym for something that isn’t a Monad instance, and in fact can’t be made into one directly (there’s no way to write [(a, String)] in the form required for an instance declaration).

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

Sidebar

Related Questions

I'm currently learning Haskell, Which language (F# or Haskell) do you prefer for programming
I'm still learning Haskell and need help with the type inference please! Using packages
I am currently learning Haskell. I am trying to write a function which given
I've recently been learning Haskell, and I noticed that the String type (or [Char]
I'm learning how to use arrays in Haskell, for example, generating a times table:
I'm learning Haskell from a Java background. When I program Java, I feel like
I am learning Haskell and I want to do TDD. I am trying to
I'm learning Haskell now and I'm facing the following problem: I want to rewrite
I have started learning Haskell from Learn You a Haskell . In one of
Learning haskell and want a function to generate a 2D grid similar to how

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.