I'm having trouble declaring multiple functions after my initial function for where
.
My function I am attempting to fix:
--initials function using where and pattern matching
initials :: String -> String -> String
initials firstname lastname = [f] ++ ". " ++ [l] ++ "."
where (f:_) = firstname
(l:_) = lastname
I currently run the file in ghci
by the command :l functionSyntax
as the file is named functionSyntax.hs
.
What am i doing wrong here? The site I am learning haskell from, LearnYouaHaskell, has their code written as:
initials :: String -> String -> String
initials firstname lastname = [f] ++ ". " ++ [l] ++ "."
where (f:_) = firstname
(l:_) = lastname
which I feel is the exact same code, but I'm receiving the error:
ghci> :l functionSyntax
[1 of 1] Compiling Main ( functionSyntax.hs, interpreted )
functionSyntax.hs:86:31: parse error on input `='
Failed, modules loaded: none.
I've tried looking up this error as it seems pretty common, but I can't seem to fix this seemingly simple problem. Any help is appreciated!