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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:59:49+00:00 2026-06-07T02:59:49+00:00

I have been trying to compile Haskell code all day – again – involving

  • 0

I have been trying to compile Haskell code all day – again – involving Control.Monad.Writer. Here is a code example that won’t compile from Learn You a Haskell:

import Control.Monad.Writer  

gcd' :: Int -> Int -> Writer [String] Int  
gcd' a b  
    | b == 0 = do  
        tell ["Finished with " ++ show a]  
        return a  
    | otherwise = do  
        tell [show a ++ " mod " ++ show b ++ " = " ++ show (a `mod` b)]  
        gcd' b (a `mod` b)

I receive this error:

No instance for (Show (Writer [String] Int))
      arising from a use of `print'
    Possible fix:
      add an instance declaration for (Show (Writer [String] Int))
    In a stmt of an interactive GHCi command: print it

I have tried compiling code my teacher wrote today also involving Control.Monad.Writer but nothing works.

I am using Ubuntu 12.04, gedit, and GHC 7.4.1.

All the Writer monad programs from Learn You a Haskell have failed to compile, and I am pretty stuck as it is.

  • 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-07T02:59:52+00:00Added an answer on June 7, 2026 at 2:59 am

    You apparently entered something like

    ghci> gcd' 12345 6789
    

    at the ghci prompt. Thus you asked ghci to print a value of type Writer [String] Int, but there’s no Show instance for Writer types, hence ghci can’t print it. You need to apply runWriter or a similar function,

    ghci> runWriter $ gcd' 12345 6789
    

    should work.

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

Sidebar

Related Questions

I have been trying to compile the project from http://www.shabdar.org/google-maps-user-control-for-ASP-Net-part1.html but it is complaining
I have been trying to compile netcat.c on AIX for some time (using the
I have been trying to compile an old project for my company, which uses
I have been trying to write some code that asks the user for several
Lately, I have been trying to compile php on my old PPC mac running
I have been trying to work through the HelloAndroid example for ORMLite but haven't
I have been trying to compile systrace (1.6g) on Ubuntu. When I am using
I have been trying to compile the application.sass in my Sencha Touch project into
I have been trying to use g++ to compile a program with SDL. The
I have been trying to follow the example at http://xacmlinfo.com/2011/12/18/writing-jdbc-pip-module/ in order to create

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.