Skip to content

Instantly share code, notes, and snippets.

@strager
Created August 27, 2013 07:06
Show Gist options
  • Select an option

  • Save strager/6350496 to your computer and use it in GitHub Desktop.

Select an option

Save strager/6350496 to your computer and use it in GitHub Desktop.
def safeHead([a] -> a?):
->xs
if (xs isEmpty):
none
else:
xs head some
def find([a] (a -> Bool) -> a?):
filter safeHead
def lookUp([a & b] a (a a -> Bool) -> b?):
->eq
->key // 33
{key eq} find // 34
{rest} liftOption
/*
stuff.ktn:33:5: note: t3332 is from here
stuff.ktn:34:5: type error: cannot solve infinite type constraint t3333 = t3333 t3332 t3339
stuff.ktn:34:5: note: this may be due to a mismatched number of arguments or results
stuff.ktn:34:6: note: t3333 is from here
stuff.ktn:34:14: note: t3339 is from here
(unknown): note: t3333 is from here
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment