I have declared the following types
data MonthData = Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec deriving ( Eq, Show, Enum, Ord )
type Year = Int
type Month = ( MonthData, Year )
type Gap = Int
type Average = Double
type HistoryElem = ( Date, Gap, Average )
type History = [ HistoryElem ]
Then, I have declared the following function
event_tests = [ ( ( 28, ( Nov, 2016 ) ), 0, 0.0 ), ( ( 27, ( Nov, 2016 ) ), 0, 0.0 ) ]
history :: Int -> HistoryElem
history 0 = head( event_tests )
When I try to load my file, I have the following error.
ERROR "ass16-1.hs":90 - Type error in explicitly typed binding
*** Term : history
*** Type : Int -> ((Integer,(MonthData,Integer)),Integer,Double)
*** Does not match : Int -> HistoryElem
It seems that it doesn't consider that HistoryElem has been previously defined because if we look carefuly, we can see that
((Integer,(MonthData,Integer)),Integer,Double) is the same definition than HistoryElem
Can't figure out what I'm doing wrong.
Datedefined?