haskell - Program design concerning ADTs -
i have type
data phase = phaseone | phasetwo | phasethree deriving enum
and 5 operations on each phase
read
write
validate
evalstatus
update
i began trying create type class. problem is, same type. i'd able like
instance myclass phasethree read = ...
also, need overload return type.
i know type classes aren't want. i'm not sure how want. thought of gadt that's not quite right need able have each instance in separate file.
i'd advice on mechanisms need investigate? have given enough information?
i recommend inverting things bit.
data phase = phase { read :: string -> foo, write :: foo -> io (), validate :: foo -> bool, evalstatus :: io (), update :: foo -> foo } phaseone, phasetwo, phasethree :: phase
(or similar rejiggering of classes explicit records).
Comments
Post a Comment