Desugaring of pattern matching function

27 views
Skip to first unread message

rvdalen

unread,
Aug 4, 2017, 7:39:22 AM8/4/17
to purescript
Hi everyone,

If I write a function using "pattern matching function" syntax:

==================

boolToString2 :: Boolean -> String

boolToString2 true = "value is true"

boolToString2 false = "value is false"


==================

Is this just syntactic sugar which really converts that syntax into:

==================

boolToString :: Boolean -> String

boolToString v =

  case v of

    true -> "value is true"

    false -> "value is false"


==================

Regards
--Rouan

Brenton Alker

unread,
Aug 4, 2017, 7:44:18 AM8/4/17
to pures...@googlegroups.com
Yep, it absolutely is.

You can see it if you look at the generated JS for both...


(check the "Show JS" checkbox)

--
You received this message because you are subscribed to the Google Groups "purescript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to purescript+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/purescript.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages