You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
jfyi, I've been using the following combinator-like approach throughout my code for the last months. I tried first with a .:/-like approach, but it didn't feel right to me.
--|Helper for use in combination with '.:?' operator(.!=)::Parser (Maybea) ->a->Parsera(.!=) p dfl = fromMaybe dfl <$> p
{-# INLINE (.!=) #-}
This allows code to be written in a ternary-operator style such as:
do
v1 <- o .:?"opt_field_with_dfl".!="default_val"
v2 <- o .:"mandatory_field"
v3 <- o .:?"opt_field2"-- whereas the `.:/` operator looks weird in comparision:
v1' <- o .:/ ("opt_field_with_dfl", "default_val")
461d898
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jfyi, I've been using the following combinator-like approach throughout my code for the last months. I tried first with a
.:/
-like approach, but it didn't feel right to me.This allows code to be written in a ternary-operator style such as:
461d898
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thinks it's a clever solution using it as a Functor.