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

Pages: 1-4041-

Haskell Types

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?

Name: Anonymous 2008-02-17 6:35

Have you tried YHBT?

Name: Anonymous 2008-02-17 6:36

>>2
Oh, you!

Name: Anonymous 2008-02-17 7:26

Yet another Haskell Beginner Tutorial.

Name: Anonymous 2008-02-17 9:22

>>1
YAHT explains it excellently. You suck dicks.

Name: Anonymous 2008-02-17 9:29

A Gentle Introduction to Haskell.

Name: Anonymous 2008-02-17 9:31

Types and Programming Languages

Name: Anonymous 2008-02-17 10:03

Name: Anonymous 2008-02-17 12:50

HELP HIM!!!

Name: Anonymous 2008-02-17 12:51

>>8
Funny, because right now I am learning Haskell and C simultaneously. Will it be helpful?

Name: Anonymous 2008-02-17 12:54

What happens when I don't declare the type of the function?

Name: Anonymous 2008-02-17 12:55

>>10
drop that zero, get with a hero

Name: Anonymous 2008-02-17 12:55

>>11
type
inference

Name: Anonymous 2008-02-17 13:01

>>13
So what, is it slower or something?

Name: Anonymous 2008-02-17 13:07

>>10
drop that zero, become and hero

Name: Anonymous 2008-02-17 13:40

drop that zero and get with a one

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.

Name: Anonymous 2008-02-17 14:11

>>14
OMG OPTIMIZED

Name: Anonymous 2008-02-17 15:51

>>17
Examples please.

Name: Anonymous 2008-02-17 16:27

>>19
x = 0

Which type is x?

Name: Anonymous 2008-02-17 16:46

>>20
OH FUCKING FUCK SHIT BLOWING UP YOU GOT ME THERE

Name: Anonymous 2008-02-17 16:55

>>20
It's a number.

Name: Anonymous 2008-02-17 17:08

>>22
Number is a class, not a type.

Name: Anonymous 2008-02-17 17:10

>>23
That's great champ

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.

Name: Anonymous 2008-02-17 17:40

>>20
(Num a) => a

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)

Name: Anonymous 2008-02-17 20:52

mapM_ (print . product . enumFromTo 1 . read) . takeWhile (/= "0") . lines =<< getContents

Name: Anonymous 2008-02-17 20:55

>>28
Lol
>>27
getNums :: [String]
dumbass

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)

Name: Anonymous 2008-02-18 6:00

>>30
Looks like Joy, ho, ho!

Name: Anonymous 2008-02-18 7:12

putStrLn considered harmful and unintuitive.

Name: Anonymous 2008-02-18 7:15

>>32
What should we use instead, oh great Wizard?

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.

Name: Anonymous 2008-02-18 7:32

>>34
That's just because you're a bad programmer.

Name: Anonymous 2008-02-18 8:07

>>34
Not all C functions require \n.  By your logic, he should be using Text.Printf.printf.

Name: Anonymous 2008-02-18 8:27

      puts
puts
    PUTS IS THE STANDARD

Name: Anonymous 2008-02-18 8:36

            PUTS!
PUTS!
     PUTS IS THE STANDARD!

Name: Anonymous 2008-02-18 9:13

Read about _IOLBF and understand why \n is importand.

Name: Anonymous 2008-02-20 17:31

bump for >>1

Name: Anonymous 2008-02-20 18:09

>>40
You think we'll help you? (even if we were able to), think again.

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.

Name: Anonymous 2008-02-21 9:24

guys

Name: Anonymous 2010-09-20 17:43

>>43
yes?

Name: Anonymous 2010-09-20 18:26

>>44
You aren't clever.

Name: Anonymous 2010-11-25 17:17

Name: Anonymous 2011-02-04 14:14

Name: Anonymous 2013-08-05 16:36

i'm gonna kick you in the monads

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