-- um Node é basicamente uma string, pra simplicidade do exemplo
-- um grafo, em que cada Node liga outros Nodes com uma distância específica
newtype Graph
= Graph
[(Node
, [(Node
, Int)])] deriving (Show)
-- um type alias para um algoritmo de busca
-- equivalente a uma interface de um método
-- implementações da interface
bfs :: GraphSearchFn
bfs g v = Nothing
dfs :: GraphSearchFn
dfs g v = Nothing
-- um ""método"" de Graph
search
:: Graph
-> GraphSearchFn
-> String -> Maybe Node
search g f = f g
main = do
let graph = Graph []
let node = search graph dfs ""
LS0gdW0gTm9kZSDDqSBiYXNpY2FtZW50ZSB1bWEgc3RyaW5nLCBwcmEgc2ltcGxpY2lkYWRlIGRvIGV4ZW1wbG8KbmV3dHlwZSBOb2RlID0gTm9kZSBTdHJpbmcgZGVyaXZpbmcgKFNob3cpCgotLSB1bSBncmFmbywgZW0gcXVlIGNhZGEgTm9kZSBsaWdhIG91dHJvcyBOb2RlcyBjb20gdW1hIGRpc3TDom5jaWEgZXNwZWPDrWZpY2EgCm5ld3R5cGUgR3JhcGggPSBHcmFwaCBbKE5vZGUsIFsoTm9kZSwgSW50KV0pXSBkZXJpdmluZyAoU2hvdykKCi0tIHVtIHR5cGUgYWxpYXMgcGFyYSB1bSBhbGdvcml0bW8gZGUgYnVzY2EKLS0gZXF1aXZhbGVudGUgYSB1bWEgaW50ZXJmYWNlIGRlIHVtIG3DqXRvZG8gCnR5cGUgR3JhcGhTZWFyY2hGbiA9IEdyYXBoIC0+IFN0cmluZyAtPiBNYXliZSBOb2RlCgotLSBpbXBsZW1lbnRhw6fDtWVzIGRhIGludGVyZmFjZQpiZnMgOjogR3JhcGhTZWFyY2hGbiAKYmZzIGcgdiA9IE5vdGhpbmcKCmRmcyA6OiBHcmFwaFNlYXJjaEZuIApkZnMgZyB2ID0gTm90aGluZwoKLS0gdW0gIiJtw6l0b2RvIiIgZGUgR3JhcGgKc2VhcmNoIDo6IEdyYXBoIC0+IEdyYXBoU2VhcmNoRm4gLT4gU3RyaW5nIC0+IE1heWJlIE5vZGUKc2VhcmNoIGcgZiA9IGYgZwoKbWFpbiA6OiBJTyAoKQptYWluID0gZG8KCWxldCBncmFwaCA9IEdyYXBoIFtdCglsZXQgbm9kZSA9IHNlYXJjaCBncmFwaCBkZnMgIiIKCXB1dFN0ckxuICQgc2hvdyBub2RlCglyZXR1cm4gKCk=