Explain a piece of Haskell code

Bobys

Does someone knows what this code does?I know its validating the given year but I didn't really get the idea of the whole process.

tempYear <- getLine
case reads tempYear :: [(Integer, String)] of
     [(n, "")] -> do let year = read tempYear :: Int
yokto

I guess the case reads is there to deal with the case in which getLine does not return a proper number. reads returns a list of possible answers. If the tempYear were to start with a non-digit the empty list would be returned. If there was some other letter or something like that in the string, then the number up to that letter would be n. But the second value in the tuple would not be the empty string but the unparsed rest of the string.

However, I don't know why he would read an Integer first and then an Int. If the two types were equal, n would also be equal to year.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Explain a piece of Haskell code

From Dev

Can somebody explain this piece of clojure code?

From Dev

Could someone please explain a piece of Javascript code?

From Dev

Can someone explain what is happening in this piece of code?

From Dev

Could you please explain this piece of code in terms of C# code?

From Dev

Can any one explain the use of '&' in this piece of ruby code?

From Dev

Strange function-like property – can someone explain this piece of Swift code?

From Dev

js Array.prototype.filter.call() - can someone explain me how this piece of code works?

From Dev

Explain why I am getting error in 1 piece of code and not in the other one

From Dev

Explain why I am getting error in 1 piece of code and not in the other one

From Dev

explain the Haskell breadth first numbering code to traverse trees

From Dev

Can someone explain this simple Haskell code to me in detail

From Dev

Can somebody explain what this piece of twisted does?

From Dev

Understanding a piece of python code

From Java

What are the parenthesis in this piece of code for?

From Dev

Why is this piece of code not faster?

From Dev

Refactoring this piece of code - Rails

From Dev

What is wrong with this piece of code?

From Dev

Is there a Python function for this piece of code?

From Dev

Is this piece of code technically valid?

From Dev

what is wrong with this piece of code?

From Dev

Is this piece of code correct?

From Dev

Matlab: Understanding a piece of code

From Dev

Explanation for a piece of javascript code

From Dev

What is the "returnto" in this piece of code

From Dev

Is there a Python function for this piece of code?

From Dev

How to parallelize this piece of code?

From Dev

Whats wrong with this piece of code?

From Dev

Javascript piece of code not working

Related Related

  1. 1

    Explain a piece of Haskell code

  2. 2

    Can somebody explain this piece of clojure code?

  3. 3

    Could someone please explain a piece of Javascript code?

  4. 4

    Can someone explain what is happening in this piece of code?

  5. 5

    Could you please explain this piece of code in terms of C# code?

  6. 6

    Can any one explain the use of '&' in this piece of ruby code?

  7. 7

    Strange function-like property – can someone explain this piece of Swift code?

  8. 8

    js Array.prototype.filter.call() - can someone explain me how this piece of code works?

  9. 9

    Explain why I am getting error in 1 piece of code and not in the other one

  10. 10

    Explain why I am getting error in 1 piece of code and not in the other one

  11. 11

    explain the Haskell breadth first numbering code to traverse trees

  12. 12

    Can someone explain this simple Haskell code to me in detail

  13. 13

    Can somebody explain what this piece of twisted does?

  14. 14

    Understanding a piece of python code

  15. 15

    What are the parenthesis in this piece of code for?

  16. 16

    Why is this piece of code not faster?

  17. 17

    Refactoring this piece of code - Rails

  18. 18

    What is wrong with this piece of code?

  19. 19

    Is there a Python function for this piece of code?

  20. 20

    Is this piece of code technically valid?

  21. 21

    what is wrong with this piece of code?

  22. 22

    Is this piece of code correct?

  23. 23

    Matlab: Understanding a piece of code

  24. 24

    Explanation for a piece of javascript code

  25. 25

    What is the "returnto" in this piece of code

  26. 26

    Is there a Python function for this piece of code?

  27. 27

    How to parallelize this piece of code?

  28. 28

    Whats wrong with this piece of code?

  29. 29

    Javascript piece of code not working

HotTag

Archive