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-19 5:28 ID:0TH3a3lL

You need to load the Char module, using :load Char

Name: Anonymous 2007-07-19 5:28 ID:cbPsxh4v

First, what does anon use for Haskell dev? GHC or Hugs?

GHC.

Also, are there any tutorials for setting Emacs up with Haskell (GHC or Hugs) under Windows?

I don't know or care about Windows, but my haskell-mode setup on Emacs 22.1 is


(add-to-list 'load-path (expand-file-name "~/.emacs.d/site-lisp/haskell-mode"))
(add-to-list 'auto-mode-alist '("\\.[Hh][Ss]\\'" . haskell-mode))

(require 'haskell-mode)
(require 'inf-haskell)

(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)


Also, I've set haskell-ghci-program-args to '("-fglasgow-exts" "-W").

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

>>2
Thanks, that seems to work.

>>3
Eh, Emacs is too hard to understand, I'll probably stick to Notepad++, but thanks anyway

Name: Anonymous 2007-07-19 5:36 ID:Heaven

Emacs is made of shit and fail.

Name: Anonymous 2007-07-19 5:39 ID:Heaven

>>5
i agree with this statement, emacs is fail and shit of made

Name: Anonymous 2007-07-19 14:46 ID:CG3pQFD6

>>4
Have you tried EclipseFP? (Haskell on Eclipse)

http://eclipsefp.sourceforge.net/

Name: Anonymous 2007-07-20 4:34 ID:Y8hfa3c4

Have you tried a text editor?

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?

Name: Anonymous 2007-07-20 6:06 ID:Mv1BTwX6

>>9
GO TO A FUCKING HASKELL BOOK SHOP NIGGAR

Name: Anonymous 2007-07-20 6:17 ID:r0vUxRWv

>>9
OP Here. Nevermind, I wrote a recursive function to do this using head and tail.

Name: Anonymous 2007-07-20 6:33 ID:Heaven

>>9
The type of map printFact numList is [IO ()], but you need to have a type of IO [()]. You can use sequence $ map printFact numList or use mapM printFact numList.

Name: Anonymous 2007-07-20 6:36 ID:r0vUxRWv

>>11
Ah, I just realized YAHT has a solutions section at the end, :P

Name: Anonymous 2007-07-20 6:55 ID:ZP3o2Ie2

>>10
Ok, I'm at the bookstore.
What do you recommend?

Name: Anonymous 2007-07-20 6:57 ID:Heaven

>>14
SICP

Name: Anonymous 2007-07-20 7:11 ID:Heaven

Name: Anonymous 2007-07-20 7:52 ID:Heaven

>>16
>>14 is not the OP. Proceed with caution

Name: Anonymous 2007-07-21 7:36 ID:AyZcLUiZ

>>14
SICP
How to Design Programs
Practical Common Lisp

Name: Anonymous 2007-07-21 12:10 ID:o898ouWD

Haskell School of Expression is actually pretty good. Not SICP good, but good nonetheless.

Name: Anonymous 2007-07-21 12:32 ID:Heaven

>>19
Expression you say? you must be talking about lisp!

Name: Anonymous 2007-07-21 13:02 ID:Heaven

>>20
How do I failed troll — Lesson 1
Fix'd.

Name: Anonymous 2008-09-30 7:15

[a]a[/a]
b
[c]c[/c]
[d]d[/d]
[e]e[/e]
[f]f[/f]
[g]g[/g]
[h]h[/h]
i
[j]j[/j]
[k]k[/k]
[l]l[/l]
m
[n]n[/n]
o
[p]p[/p]
[q]q[/q]
[r]r[/r]
s
[t]t[/t]
u
[v]v[/v]
[w]w[/w]
[x]x[/x]
[y]y[/y]
[z]z[/z]

Name: Anonymous 2008-09-30 7:31

[mark red]mark[/mark]
sup

Name: Anonymous 2009-01-14 14:55

IHBT

Name: Anonymous 2010-12-10 7:20

Name: Anonymous 2011-09-14 1:49

http://wktk.vip2ch.com/vipper16834.jpg

"magical (star) haskell"

Name: Anonymous 2011-09-14 9:27

>>9

Your code is fucked. I don't know what you people are shit at this, but the first line should be
fact 0 = 1

Name: Anonymous 2011-09-14 10:05

>>28
LOL!

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