[Haskell-cafe] Very binding semicolon
Branimir Maksimovic
branimir.maksimovic at gmail.com
Tue Sep 28 10:38:10 UTC 2021
Why this works :P
bmaxa at Branimirs-Air haskell % ghc -O2 semi.hs
Loaded package environment from /Users/bmaxa/.ghc/aarch64-darwin-8.10.7/environments/default
[1 of 1] Compiling Main ( semi.hs, semi.o )
Linking semi ...
bmaxa at Branimirs-Air haskell % ./semi
[1,2,3,3,2,1]
bmaxa at Branimirs-Air haskell % cat semi.hs
main = do
let lst = lrl [1,2,3]
print lst
; ; ; ; ; ; ; ;;;;lrl :: [a]->[a]; ;; ; ; ; ; lrl xs = xs ++ reverse xs
> On 28.09.2021., at 12:00, Anthony Clayden <anthony.d.clayden at gmail.com> wrote:
>
> From the department of improbable syntax/I don't get how this works, but it does:
>
> > f :: [a] -> [a]
> > ;; f xs = xs ++ reverse xs
>
> Nicely (to my eye) groups/indents the binding under the signature. Especially handy with ScopedTypeVariables, to show how the scoped vars 'belong'
>
> > f :: forall a. [a] -> [a]
> > ;; f xs = xs ++ ys
> > where
> > ys :: [a]
> > ys = reverse xs
>
> The doubled `;;` stands out like a ditto. It could be a single semicolon (which means there's an empty decl/binding between the semis -- I don't see that's allowed by the syntax).
>
> Unfortunately, for multi-line bindings you need to repeat the `;;`
>
> > f :: [a] -> [a]
> > ;; f [] = []
> > ;; f xs = xs ++ reverse xs
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210928/ea8fea6b/attachment.html>
More information about the Haskell-Cafe
mailing list