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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:02:53+00:00 2026-06-08T09:02:53+00:00

I am ploughing through Learn You a Haskell for Great Good , and I

  • 0

I am ploughing through Learn You a Haskell for Great Good, and I have reached up to section 8.4, “Derived Instances”. In this section, there’s the following data type declaration:

data Person = Person { firstName :: String  
                     , lastName :: String  
                     , age :: Int  
                     } deriving (Eq)

While trying

*Main> mikeD == Person {firstName = "Michael", lastname = "Diamond", age = 43}

I got the following error:

<interactive>:55:41:
`lastname' is not a (visible) field of constructor `Person'

By correcting lastname to lastName I removed the error.

Question:

In the error message the word (visible) hints to me that there must be the possibility of declaring a field as hidden / invisible. Is this correct or not? If it is, how can I declare a field in the constructor as hidden, and what are the general scenarios where one would need to declare hidden fields? If you could explain this by giving a simple example of their use, that would be appreciated.

Note: I could not find any reference to/details about hidden or invisible field in LYAH.

  • 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-08T09:02:54+00:00Added an answer on June 8, 2026 at 9:02 am

    It is possible to hide a field of a record, or a constructor of any data type, although not at the declaration site. The idea is to simply choose not to export that constructor and/or field from the module, like so:

    module MyModule (DT(C1, int, mStr)) where
    
    data DT = C1 -- visible
                 { 
                   int :: Int, -- visible
                   str :: String -- hidden
                 }
            | C2 -- hidden
                 {
                   dbl :: Double, -- hidden
                   mStr :: Maybe String -- visible
                 }
    

    Note that everything inside MyModule still has access to both constructors and all four fields, but in some other module that imports MyModule only the exported ones are visible.

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

Sidebar

Related Questions

OK, I'm pretty new to this, and ploughing through all the tutorials and answered
I have a projectile that I would like to pass through specific coordinates at
I am trying to make a plugging using JS. I have the following code
I'm ploughing ahead in my attempts to learn Mootools (damn, I miss Consider Open's
Is there a good QR Decoding Script or Pluging for Unity3D (Android and iOS)?
I have a dojo.store.Memory wrapped in a dojo.data.ObjectStore which I am then plugging into
First off I apologize... I have posted this question before, but I did a
I honestly have little clue what facts are relevant to this issue, so I'll
I am trying to learn more about Javascript, I have been coding with PHP
I am using rails with jquery gem. I have the following in my application.js

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.