season
この関数は代数関数を使用していますが、コードを繰り返しているような気がします。
できるだけ短くするにはどうすればよいですか?
data Month = Jan | Feb | Mar | Apr | May | June | July | Aug | Sept| Oct | Nov | Dec
deriving (Eq,Ord,Show,Read)
data Seasons = Spring | Summer | Autumn | Winter
deriving (Eq,Ord,Show,Read)
season :: Month -> Seasons
season Jan = Winter
season Feb = Winter
season Mar = Spring
season Apr = Spring
season May = Spring
season June = Summer
season July = Summer
season Aug = Summer
season Sept = Autumn
season Oct = Autumn
season Nov = Autumn
season Dec = Winter
関数とコンストラクターの名前を1文字に変更すると、%短縮されます)
—
luqui