0

Hi im trying to write a simple function using the standard library

it should take the following argument

try = fn: 'a -> 'b list option
a_list = 'a list

and the defintion is the following:

fun all_answers try a_list = 
  let fun acc(SOME(a), SOME(b)) = SOME(b@a)
        | acc(_,_)              = NONE
  in
    List.foldl (fn(x,y) => acc(try(x), y)) SOME([]) a_list
  end

and i get the following error:

hw3provided.sml:70.3-70.60 Error: operator and operand don't agree [tycon mismatch]
  operator domain: 'Z list option
  operand:         'Y -> 'Y option
  in expression:
    (List.foldl (fn (<pat>,<pat>) => acc <exp>)) SOME
C:\Program Files (x86)\SMLNJ\\bin\.run\run.x86-win32.exe: Fatal error -- Uncaught exception Error         with 0
 raised at ../compiler/TopLevel/interact/evalloop.sml:66.19-66.27

ive tried decomposing the function and the error seems to correspond to the use of SOME([]), if i use NONE instead it typechecks perfectly

I am at a total loss here

just incase its significant im using the sublime repl to run the script

user25470
  • 585
  • 4
  • 17

1 Answers1

1

figured out the solution but not really the problem

surround the SOME([]) with brackets (SOME([]))

just in case anybody else comes across the same issue

user25470
  • 585
  • 4
  • 17
  • You don't need the brackets around `[]`, though - `(SOME [])` would be more idiomatic (thus more readable to most). – molbdnilo Oct 30 '14 at 12:51