Because the Seq
module already has a head
function of type seq<'a> -> 'a
, I would define a function tryHead
with signature seq<'a> -> option<'a>
:
module Seq =
let tryHead (ls:seq<'a>) : option<'a> = ls |> Seq.tryPick Some
using it as:
[1; 2; 3] |> Seq.tryHead