On Friday, March 3, 2017 at 1:12:39 AM UTC-5, Richard Feldman wrote:
>
> There have been various discussions of potential ways to improve Elm's 
> record update syntax. Evan commented that "(examples > design work) at this 
> point" - any potential designs for syntax improvements would need to be run 
> through a gauntlet of examples to see how well they'd work, so the first 
> step in the process is to gather those examples.
>
> So let's collect a ton of different real-world examples! That will help 
> guide the design process.
>
> If you've run into a record update that you felt was painful and could be 
> improved in some way, please post it here! (Also, *please keep this 
> thread for posting of examples* *only* - it'll be easier to link back 
> here during design discussions if we can reference a clean thread of 
> examples, as opposed to a mismash of examples interleaved with suggestions.)
>

Hi all, Richard asked me to post to this thread based on a discussion we 
had. Following along with some running themes here, I'm working with nested 
Maybes, and combinations of Maybes with union types, which can quickly lead 
to deeply nested patterns. Current code:

moveLeft : ExpressionTree -> ExpressionTree
moveLeft content =
    case (activeBuffer content) of
        Just buffer ->
            case buffer of
                BufferContent buffer ->
                    case buffer.cursor of
                        Just cursor ->
                            if Cursor.atStart buffer cursor then
                                content -- @TODO Shift last prev onto 
current
                            else
                                -- ...
                        Nothing ->
                            content
                _ ->
                    content
        Nothing ->
            content

Theoretical future code:

moveLeft content =
    case activeBuffer content of
        Just (BufferContent { cursor = Just cursor }) ->
            if atStart buffer cursor then
                content
                -- @TODO Shift last prev onto current
            else
                -- ...

        _ ->
            content

Being able to destructure within a pattern match would save some extra 
boilerplate.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to