I declare some data type as follow:
data TX_OR_TY = TX | TY data TX = X Int data TY = Y Float
Now I write some function return their data type:
funcTX :: TX funcTX = X 3 funcTY :: TY funcTY = Y 5 ordFuncTX :: TX -> Int -> Bool ordFuncTX (X a) b = (a > b) funcTX_TY :: TX_OR_TY funcTX_TY = if (ordFuncTX funcTX 4) then funcTX else funcTY
Function funcTX_TY will return a type of TX_OR_TY by comparing the value of TX with 4, if bigger then return TX, if smaller then return TY. But when compiling, it announces that it couldn't match expected type TX_OR_TY with TX. How can I fix?