
#12376: Allow function definitions in record syntax -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Replying to [comment:3 Iceland_jack]:
A hypothetical `\case2` may be better
{{{#!hs eqList a = MkEq { (==) = \case2 ([], []) -> True (x:xs, y:ys) -> ... (_, _) -> False , (/=) = neqDef (eqList a) } }}}
Given an extension that allows user to omit tuple parentheses when un- ambiguous (similar to Agda's `_,_` constructor which looks like `a , b` when applied to two arguments) this looks even better
{{{#!hs eqList a = MkEq { (==) = \case2 [], [] -> True x:xs, y:ys -> ... _, _ -> False , (/=) = neqDef (eqList a) } }}}
Why not go all the way and allow the full syntax of function definitions here, just as in a module scope, in an instance declaration, in a where clause or in a let clause: {{{#!hs eqList a = MkEq { [] == = True (x:xs) == (y:ys) = … _ == _ = False , (/=) = neqDef (eqList a) } }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12376#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler