Haskell Types
1
Name:
Anonymous
2008-02-17 6:34
So I've been learning Haskell for some time, I get some basic and intermediate stuff, some monad basics, but could anyone recommend a good tutorial that explains type system better than YAHT?
2
Name:
Anonymous
2008-02-17 6:35
Have you tried YHBT?
3
Name:
Anonymous
2008-02-17 6:36
4
Name:
Anonymous
2008-02-17 7:26
Y et another H askell B eginner T utorial.
5
Name:
Anonymous
2008-02-17 9:22
>>1
YAHT explains it excellently. You suck dicks.
6
Name:
Anonymous
2008-02-17 9:29
A Gentle Introduction to Haskell .
7
Name:
Anonymous
2008-02-17 9:31
Types and Programming Languages
8
Name:
Anonymous
2008-02-17 10:03
9
Name:
Anonymous
2008-02-17 12:50
HELP HIM!!!
10
Name:
Anonymous
2008-02-17 12:51
>>8
Funny, because right now I am learning Haskell and C simultaneously. Will it be helpful?
11
Name:
Anonymous
2008-02-17 12:54
What happens when I don't declare the type of the function?
12
Name:
Anonymous
2008-02-17 12:55
>>10
drop that zero, get with a hero
13
Name:
Anonymous
2008-02-17 12:55
14
Name:
Anonymous
2008-02-17 13:01
>>13
So what, is it slower or something?
15
Name:
Anonymous
2008-02-17 13:07
>>10
drop that zero, become and hero
16
Name:
Anonymous
2008-02-17 13:40
drop that zero and get with a one
17
Name:
Anonymous
2008-02-17 13:57
>>14
No. Sometimes it can be ambiguous and you will have to help the compiler by providing type annotations, but generally most of the types your code can be inferred at compile time.
18
Name:
Anonymous
2008-02-17 14:11
19
Name:
Anonymous
2008-02-17 15:51
20
Name:
Anonymous
2008-02-17 16:27
>>19
x = 0
Which type is
x?
21
Name:
Anonymous
2008-02-17 16:46
>>20
OH FUCKING FUCK SHIT BLOWING UP YOU GOT ME THERE
22
Name:
Anonymous
2008-02-17 16:55
23
Name:
Anonymous
2008-02-17 17:08
>>22
Number is a class, not a type.
24
Name:
Anonymous
2008-02-17 17:10
25
Name:
Anonymous
2008-02-17 17:15
module Main
where
import IO
getNums = do
putStrLn "give numbers"
number <- getLine
if number == "0"
then return []
else do
rest <- getNums
let final = (number : rest)
in return final
How do I make it return list of factorials of final? What I thought about was mapping read across final, then mapping fact on the list of numbers, but it doesn't work.
26
Name:
Anonymous
2008-02-17 17:40
27
Name:
Anonymous
2008-02-17 17:46
>>25
module Main where
import IO
getNums = do
putStrLn "give numbers"
line <- getLine
let number = read line
if number == 0
then return []
else do
rest <- getNums
return (number : rest)
fact n = product [1 .. n]
getFacts = do
nums <- getNums
return (map fact nums)
28
Name:
Anonymous
2008-02-17 20:52
mapM_ (print . product . enumFromTo 1 . read) . takeWhile (/= "0") . lines =<< getContents
29
Name:
Anonymous
2008-02-17 20:55
>>28
Lol
>>27
getNums :: [String]
dumbass
30
Name:
Anonymous
2008-02-18 5:30
>>29
getNums :: IO [Integer]
>>28
main = interact (unlines . map (show . product . enumFromTo 1) . takeWhile (0 /=) . map read . lines)
31
Name:
Anonymous
2008-02-18 6:00
>>30
Looks like Joy, ho, ho!
32
Name:
Anonymous
2008-02-18 7:12
putStrLn considered harmful and unintuitive.
33
Name:
Anonymous
2008-02-18 7:15
>>32
What should we use instead, oh great Wizard?
34
Name:
Anonymous
2008-02-18 7:20
>>33
putStr, like in all languages. When I code in C I often find myself forgetting the
\n.
35
Name:
Anonymous
2008-02-18 7:32
>>34
That's just because you're a bad programmer.
36
Name:
Anonymous
2008-02-18 8:07
>>34
Not all C functions require \n. By your logic, he should be using Text.Printf.printf.
37
Name:
Anonymous
2008-02-18 8:27
puts
puts
PUTS IS THE STANDARD
38
Name:
Anonymous
2008-02-18 8:36
PUTS!
PUTS!
PUTS IS THE STANDARD!
39
Name:
Anonymous
2008-02-18 9:13
Read about _IOLBF and understand why \n is importand.
40
Name:
Anonymous
2008-02-20 17:31
41
Name:
Anonymous
2008-02-20 18:09
>>40
You think we'll help you? (even if we were able to), think again.
42
Name:
Anonymous
2008-02-20 18:15
>>41
Yes, we will. We are not a bunch of cretins that find doubtful relish in not giving help. There shall be waiting, but we will help.
Well, not me, because I don't know shit about haskell.
43
Name:
Anonymous
2008-02-21 9:24
guys
44
Name:
Anonymous
2010-09-20 17:43
45
Name:
Anonymous
2010-09-20 18:26
46
Name:
Anonymous
2010-11-25 17:17
48
Name:
Anonymous
2011-02-04 14:14