I have the following simple code
import Data.String.Regex import Data.Array last <$> match someRegex " 1"
Where
match someRegex " 1"
returns something like
Just ([Just (" 1"),Just (" "),Just ("1")])
and
last <$> match someRegex " 1"
returns something like
Just (Just (Just (" 1")))
Now I have a deeply enclosed Maybe. This makes it difficult to work with (even using functors). I wrote myself a couple of helper functions, but I'm kind of unhappy with this. It somehow doesn't seem right.
extract j = do case j of Nothing -> Nothing Just a -> a extract2 jj = extract $ extract jj
And then using this,
extract2 $ last <$> match someRegex " 1"
Is there a better / idiomatic way to do such things in Purescript / Haskell?
source share