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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:16:32+00:00 2026-05-28T11:16:32+00:00

Here is a code taken from http://www.angelfire.com/tx4/cus/shapes/haskell98.html . It compiles and executes correctly in

  • 0

Here is a code taken from http://www.angelfire.com/tx4/cus/shapes/haskell98.html .
It compiles and executes correctly in WinGHCi if I comment the names in the module header. But if the names are kept then it does not compile – it reports an error on the name MakeCircle. My question is: if I want to explicitly mention that I want to export MakeCircle, what code changes are required?

module Circle -- (Circle, MakeCircle, getRadius, setRadius)
  where
  import Shape

  class Shape a => Circle a where
      getRadius :: a -> Int
      setRadius :: a -> Int -> a

  instance Shape CircleInstance where
      getX = x
      getY = y
      setX a newx = a {x = newx}
      setY a newy = a {y = newy}
      moveTo a newx newy = a {x = newx, y = newy}
      rMoveTo a deltax deltay = a {x = ((getX a) + deltax), y = ((getY a) + deltay)}
      draw a =
         putStrLn ("Drawing a Circle at:(" ++ (show (getX a)) ++ "," ++ (show (getY a)) ++
            "), radius " ++ (show (getRadius a)))

   instance Circle CircleInstance where
      getRadius = radius
      setRadius a newradius = a {radius = newradius}

   data CircleInstance = MakeCircle {x, y, radius :: Int}
      deriving(Eq, Show)
  • 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-28T11:16:33+00:00Added an answer on May 28, 2026 at 11:16 am

    MakeCircle is a data constructor for the type CircleInstance. Data constructors can only be exported in combination with their defining type. You will probably also want to export the Circle class methods getRadius and setRadius; with the current export list those methods will be unavailable outside this module.

    Change your export list to

    module Circle (Circle (..), CircleInstance (MakeCircle), getRadius, setRadius)
    

    This shows two forms of exporting. The export Circle (..) exports the type class Circle and all of its methods, while CircleInstance (MakeCircle) exports the type constructor CircleInstance and only its data constructor MakeCircle. If you were to add a new data constructor for MakeCircle, perhaps a UnitCircle, that constructor wouldn’t be exported from the module unless you either mention it in the export list (i.e. CircleInstance (MakeCircle, UnitCircle) ) or use the (..) form of exports.

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

Sidebar

Related Questions

The php code of barcode generator (which take from here http://www.barcodephp.com/en/userguide ) looks like
I'm working with a C# sample application (taken from here : http://www.piccoder.co.uk/content/view/42/26/1/4/ ) The
This is the code taken from http://code.google.com/p/crawler4j/ and the name of this file is
Please see the attached image: 1) I downloaded a new library here: ( http://www.java2s.com/Code/Jar/ABC/Downloadcommonslang24jar.htm
How should I understand $(select option:selected) in the following code ? (taken from here
I've taken the accordion menu from http://www.i-marco.nl/weblog/ and have customised it to what I
I have a user input form here: http://www.7bks.com/create (Google login required) When you first
I am trying to utilize the example cited here: http://www.physicsforums.com/showthread.php?t=248191 I wrote a simple
you can view full source code here dpaste.com/hold/167199 Error: delete() takes exactly 2 arguments
Here is code from MSDN . I don't understand why the work isn't just

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.