2013-12-20 165 views
1

有没有简化包含类的函数类型头的方法?命名类实例

现在我写

myfce :: Graph gr => Sometype -> gr Int String 

,我想

myfce :: Sometype -> MyGraph 

回答

3

如果MyGraphx Int String一种代名词,其中xGraph一个实例,那么你可以这样做:

data GraphType a b = ... 

instance Graph GraphType where ... 

type MyGraph = GraphType Int String 

您可以然后专门myfce有你想要的类型

myfce :: Sometype -> MyGraph