Re: [elm-discuss] Re: pattern matching on a field within a record

2016-09-24 Thread Martin DeMello
On Sat, Sep 24, 2016 at 9:11 PM, Nick H wrote: > > Regarding null_square: If you want to make sure that null_square is passed > by reference, you can define it as a top-level value. (That said, the > record is so small, I doubt it would make a noticeable performance > difference, unless you're pl

Re: [elm-discuss] Re: pattern matching on a field within a record

2016-09-24 Thread Nick H
Re: your initial post... you could rewrite the code as case Maybe.map .cell c of Just (Letter s) -> s _ -> "" Don't know if that's any easier to read, though. Regarding null_square: If you want to make sure that null_square is passed by reference, you can define it as a top-level val

Re: [elm-discuss] Re: pattern matching on a field within a record

2016-09-24 Thread Martin DeMello
Don't think that will work because c is of type Maybe Square, not Maybe Cell. One further question - if I define let null_square = { cell = Empty, num = 0 } let get_square maybe_square = case maybe_cell of Nothing: null_square Just s : s let get_letter maybe_square = case maybe_squa

[elm-discuss] Re: pattern matching on a field within a record

2016-09-23 Thread Simon
This should work case c of Just (Letter s) -> s _ -> "" On Friday, 23 September 2016 03:50:19 UTC+2, Martin DeMello wrote: > > If I have the following code: > > type Cell = Empty | Letter String > > type alias Square = > { cell : Cell > , num : Int > } > > and c : Maybe S

[elm-discuss] Re: pattern matching on a field within a record

2016-09-22 Thread Max Goldstein
I don't think there's a more compact way to do that, no. -- 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 elm-discuss+unsubscr...@googlegroups.com. For more option