Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell questions

Name: Anonymous 2007-07-19 5:21 ID:v7kq1cqT

Hi, I recently decided to give Haskell another whirl, so this will become my ``Newbie Question'' thread.

First, what does anon use for Haskell dev? GHC or Hugs? Also, are there any tutorials for setting Emacs up with Haskell (GHC or Hugs) under Windows? I can't figure this out...

Next, I'm wondering why the following code doesn't work in Hugs, yet works fine in the GHC REPL:

Hugs> map toUpper "Hello World"
ERROR - Undefined variable "toUpper"
Hugs> map Char.toUpper "Hello World"
ERROR - Undefined qualified variable "Char.toUpper"

In `Yet Another Haskell Tutorial,' it says Hugs doesn't like fully qualified names, yet as you can see it fails on both qualified and unqualified. The latter input works in GHC, btw.

Thanks anon, I'll probably ask more questions if need be...

Name: Anonymous 2007-07-20 5:23 ID:r0vUxRWv

OP here

>>7
Thanks, I wasn't aware there was an Eclipse plugin for Haskell. I'm using this now :)

Anyway, I'm doing the exercise in Yet Another Haskell Tute on pg 36, and I'm a bit stuck.

Given a list of integers, I need to print out each members factorial. Seems simple enough (pretend getNumList returns a list of numbers, full code removed)

module Main where

import System

fact 1 = 1
fact n = n * fact (n - 1)
printFact n = do
    putStrLn ((show n) ++ " factorial is " ++ (show (fact n)))

main = do
    numList <- getNumList
    map printFact numList   
    System.system "pause"
    return 0

I would think that the map function applies a function onto each member of a list, however I get an error `` Couldn't match expected type `IO' against inferred type `[]' ''
Uhm, okay. So I try:

let a = map printFact numList

which eliminates the error, yet produces no output. What's wrong here?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List