error define a template haskell function -
i beginning learn template haskell, want create function receive string param define name function generate
build_p5 :: string -> [dec] build_p5 name = [ fund p1 [ clause [tupp [varp a,varp b]] (normalb (appe (vare c) (vare a))) [fund c [clause [varp a] (normalb (vare a)) []]] ] ] p1 = mkname name = mkname "a" b = mkname "b" c = mkname "ident"
to run definition :
$(build_p5 "hola")
but when run program following error
couldn't match type ‘[dec]’ ‘q [dec]’ expected type: decsq actual type: [dec] in expression: build_p5 "hola"
correct code
build_p2 :: monad m => string -> m [dec] build_p2 name = return [ fund p1 [ clause [tupp [varp a,varp b]] (normalb (appe (vare c) (vare a))) [fund c [clause [varp a] (normalb (vare a)) []]] ] ] p1 = mkname name = mkname "a" b = mkname "b" c = mkname "ident"
Comments
Post a Comment