title: generate calendar of a given month and year in haskell
body: <p>I have been learning haskell since a week and is facing different problems. This time I have to create a calendar from a given month and year. I am almost done but the problem is that I could not start filling days from starting day.</p>
  
  <p>My solution is </p>
  
  <pre><code>getDaysInMonth year month=(nDays,sDay) 
                            where nDays = gregorianMonthLength year month
                                  sDay= digitToInt(last(showWeekDate (fromGregorian year month 01)))
  year=2013
  month=10
  months=["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"]
  mnth=months!!(month-1)
  monthDate = getDaysInMonth year month
  startAt=snd(monthDate)
  totalDays = fst(monthDate)
  printLine = "\n"++concat ["+---\t" | r &lt;- [1..7]]
  check x | x&gt;totalDays=""
          | x&lt;=totalDays=show x
  genDays n m="\n "++concat[check(x)++"\t|"|x&lt;-[n..m]]
  genD 6=""
  genD sP=genDays ((sP-1)*7+1) (sP*7) ++genD (sP+1)
  generateCalendar=printLine++"\n "++
                          concat [[r]++"\t|" | r &lt;- mnth]++printLine++
                          "\n Sun\t|Mon\t|Tue\t|Wed\t|Thu\t|Fri\t|Sat"++printLine++
                          genD 1
  main=do
       putStrLn generateCalendar
  </code></pre>
  
  <p>Output of this program is like this</p>
  
  <pre><code>+---+---+---+---+---+---+---    
   O  |C  |T  |O  |B  |E  |R  |
  +---+---+---+---+---+---+---    
   Sun|Mon|Tue|Wed|Thu|Fri|Sat
  +---+---+---+---+---+---+---    
   1  |2  |3  |4  |5  |6  |7  |
   8  |9  |10 |11 |12 |13 |14 |
   15 |16 |17 |18 |19 |20 |21 |
   22 |23 |24 |25 |26 |27 |28 |
   29 |30 |31 |   |   |   |   |
  </code></pre>
  
  <p>So the problem is that October month should start from Monday. I think the implementation of the solution is little mess but how can I solve this problem ?</p>
  
  <p>Thanks in advance</p>