{-
   Copyright 2007 Dino Morelli

   This file is part of storylen

   storylen is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   storylen is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with storylen; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
   02110-1301  USA
-}

module StoryLen.Describe (
   describeStory
)
   where


type Ranges = [(Maybe Int, String)]


-- Evaluates to a descriptive string for the story length based on the
-- number of words.
describeStory :: Int -> String
describeStory = describeStory' rDefault
   where
      describeStory' :: Ranges -> Int -> String
      describeStory' _                           0 = "NO WORDS!"
      describeStory' []                          _ = "ERROR!"
      describeStory' ((Nothing  , label):_     ) _ = label
      describeStory' ((Just size, label):ranges) l
         | l <= size = label
         | otherwise = describeStory' ranges l


-- These are story length categorizations found on the web. At present
-- I've chosen to use the ones from Wikipedia.

rDefault = rWikipedia

rWikipedia :: Ranges
rWikipedia = [
   (Just 2000, "flash fiction"),
   (Just 7500, "short story"),
   (Just 17500, "novellette"),
   (Just 60000, "novella"),
   (Just 199999, "novel"),
   (Nothing, "epic")
   ]

rKayeMasterson :: Ranges
rKayeMasterson = [
   (Just 100, "micro-fiction"),
   (Just 1000, "flash fiction"),
   (Just 7500, "short story"),
   (Just 20000, "novellette"),
   (Just 50000, "novella"),
   (Just 110000, "novel"),
   (Nothing, "epic")
   ]

