funcexpr: /* This is a function: arguments -> string list */
LPAREN HEAD arguments RPAREN { let head a = [List.hd (List.hd a)] in head << $3 }
| LPAREN REAR arguments RPAREN { let rear b = List.tl (List.hd b) in rear << $3 }
| LPAREN ERECT arguments RPAREN { let erect c = List.append (List.hd c) (List.hd (List.tl c)) in erect << $3 }
;
arguments: /* This is a list of functions */
PARAM { let func p = p in func }
| funcexpr { [$1] }
| arguments arguments { List.append $1 $2 }
Returns an error: Error: This expression has type string list -> string list but an expression was expected of type string list -> string list list Type string is not compatible with type string list
I think that we need to somehow put func into a list, but every way I've tried doesn't seem to work! Any help appreciated..
I assume you are trying to compose functions with the << operator you have defined elsewhere.
Unfortunately $3 does not represent a function but a list of functions, therefore you need to do something to $3 before composing the functions.