Find git executable at run time
[git-darcs-import.git] / src / English.lhs
blobb3df17871328d6d4359fba0e388a986a951dcb75
1 % Copyright (C) 2008 Eric Kow
3 % This program is free software; you can redistribute it and/or modify
4 % it under the terms of the GNU General Public License as published by
5 % the Free Software Foundation; either version 2, or (at your option)
6 % any later version.
8 % This program is distributed in the hope that it will be useful,
9 % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 % GNU General Public License for more details.
13 % You should have received a copy of the GNU General Public License
14 % along with this program; see the file COPYING. If not, write to
15 % the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 % Boston, MA 02110-1301, USA.
19 \begin{code}
20 module English where
22 import Data.List (isSuffixOf)
24 -- | > englishNum 0 (Noun "watch") "" == "watches"
25 -- > englishNum 1 (Noun "watch") "" == "watch"
26 -- > englishNum 2 (Noun "watch") "" == "watches"
27 englishNum :: Numbered n => Int -> n -> ShowS
28 englishNum x = if x == 1 then singular else plural
30 -- | Things that have a plural and singular spelling
31 class Numbered a where
32 plural :: a -> ShowS
33 singular :: a -> ShowS
35 -- | This only distinguishes between nouns with a final -ch,
36 -- and nouns which do not.
37 -- More irregular nouns will just need to have their own type
39 -- > plural (Noun "batch") "" == "batches"
40 -- > plural (Noun "bat") "" == "bats"
41 -- > plural (Noun "mouse") "" == "mouses" -- :-(
42 newtype Noun = Noun String
44 instance Numbered Noun where
45 -- more irregular nouns will just need to have their own type
46 plural (Noun s) | "ch" `isSuffixOf` s = showString s . showString "es"
47 plural (Noun s) = showString s . showChar 's'
48 singular (Noun s) = showString s
50 -- | > singular This (Noun "batch") "" == "this batch"
51 -- > plural This (Noun "batch") "" == "these batches"
52 data This = This Noun
54 instance Numbered This where
55 plural (This s) = showString "these " . plural s
56 singular (This s) = showString "this " . singular s
57 \end{code}