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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:29:43+00:00 2026-06-10T21:29:43+00:00

Please tell me what is the problem? data Stack’ v = Stack’ [v] Int

  • 0

Please tell me what is the problem?

data Stack' v = Stack' [v] Int deriving (Show)
...
type StackInt = Stack' Int 

main = print(StackInt [1,2,3] 4)

The error i am getting is

Not in scope: data constructor `Stackint'

What is wrong?

  • 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-10T21:29:45+00:00Added an answer on June 10, 2026 at 9:29 pm

    It looks to me like you are confusing the concepts of types and constructors, this is a common problem as they live in separate namespaces and are often given the same name. In the Haskell expression

    data SomeType = SomeType Int
    

    say, you are actually defining the type SomeType and a constructor SomeType. The type is not a function in the normal sense, but the constructor is. If you asked ghci for the type of SomeType you would get this:

    :t SomeType
    SomeType :: Int -> SomeType
    

    Now, a type declaration is just a shorthand for a longer type definition, in your case making StackInt a synonym of Stack' Int. But in order to construct a value of this type you still need to use the constructor Stack' (which has type [v] -> Int -> Stack' v). So your code should be

    data Stack' v = Stack' [v] Int deriving (Show)
    
    main = print(Stack' [1,2,3] 4)
    

    If you wanted to be sure that the type was Stack' Int then you could add a function

    data Stack' v = Stack' [v] Int deriving (Show)
    
    stackInt :: [Int] -> Int -> Stack' Int
    stackInt list i = Stack' list i
    
    main = print(stackInt [1,2,3] 4)
    

    EDIT: Not also that I’ve written stackInt list i = Stack' list i for transparency here, but you can write it more elegantly just as stackInt = Stack'. It is the type constraint that makes sure that you get the right type here.

    You could also have both the new function and the type synonym if you wanted, ie

    data Stack' v = Stack' [v] Int deriving (Show)
    type StackInt = Stack' Int
    
    stackInt :: [Int] -> Int -> StackInt
    stackInt list i = Stack' list i
    
    main = print(stackInt [1,2,3] 4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I won't create wallpaper-application but have one problem. Please tell me how add ImageView
I am a learner and i have a problem data binding the dataset. Please
Please tell me there is a better solution to querying a remote Access database!
Please tell me will BlackBerry application till OS 7.1 work for new BlackBerry OS
Please tell, how can i determine, the browser supports canvas (paperjs), or not ?
Please tell me if I got this wrong. Anchor point is like a movable
Please tell me what is the Qt equivalent function for glutswapbuffers()..
Please tell me why my window doesn't render. Below is the javascript that i
Please tell me if it is possible to do the following: create an instance
Please tell me what will the call to given function return and how? 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.