
21 Apr
2014
21 Apr
'14
9:26 a.m.
On Mon, Apr 21, 2014 at 10:06 AM, Nishant
Hi,
Do I need to define indices and elem for Graph a w here explicitly ?
import Data.Array
data Graph a w = Array a [(a,w)] -- array (1,3) [(1,[(2,3),(3,2)])]
You probably meant to make "Graph a w" a type synonym but you used "data" thus it is a type constructor with one data constructor named Array which takes two parameters : an "a" and a list of pairs of "a" and "w". You wanted to write :
type Graph a w = Array a [(a,w)]
which should work better (indices will work on it like on an Array from Data.Array). -- Jedaï