-- Shorthand map over List-likef <$ lx = map f lx -- <$> in Haskelllx $> f = map f lxinfixr 2 <$infixr 2 $>-- Shorthand sequential applicationlf <$$ lx = zipWith (\f x -> f x) lf lx -- <*> in Haskelllx $$> lf = zipWith (\f x -> f x) lf lx -- <**> in Haskellinfixr 1 <$$infixr 1 $$>--Shorthand map over Maybef <? mx = case mx of -- <$> in Haskell(Just x) -> Just (f x)Nothing -> Nothingmx ?> f = case mx ofJust x -> Just (f x)Nothing -> Nothinginfixr 2 <?infixr 2 ?>-- Shorthand sequential applicationmf <?? mx = if isJust mx && isJust mf -- <*> in Haskellthen Just <| (\(Just f) (Just x) -> f x) mf mxelse Nothingmx ??> mf = if isJust mx && isJust mf -- <**> in Haskellthen Just <| (\(Just f) (Just x) -> f x) mf mxelse Nothinginfixr 1 <??infixr 1 ??>
toShape : Obj -> Maybe Shape
toShape obj = case (obj.shape, obj.shapeDimensions) of("circle", {radius}) -> Circle <? radius("rectangle", {extents}) -> Rectangle <? extents("oblong", {extents, cornerRadius}) -> Oblong <? extents <?? cornerRadius
onePxOutlined black <$ [ {- ....bunch of paths to stroke.... -} ]
I have been thinking about this as well since I tend to use F/A/M a lot in my elm code. My original idea was to use <~ and ~ (https://github.com/maxsnew/Generic/blob/master/Generic/Apply/Maybe.elm) but this is actually pretty unusable in elm right now because you can't qualified import symbols so you can only use one <~ and ~ per module.
The problem with the other approach is that you need to come up with a new symbol for every F/A/M you find. I tend to use the State monad a lot, so what should that get? #? <#, <##, #>>=? It's definitely getting difficult to understand.
In the mean-time, I'm going to go the `elmo` way and try to minimize my use of operators since they're so hard to use with modules, but I don't buy in to the operator-hate that people have here.
Oh and as a side-note, your <$$ and $$> don't correspond to the default applicative instance for [] in Haskell, they correspond to the one for http://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Applicative.html#t:ZipList and in Elm that instance is technically not an Applicative because there's no way to define `pure` without infinite lists (you need a lazy data structure for that).
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Real Programmers (TM) use meaningfulCamelCaseIdentifiers.
--
(The hints at elm-lang.org/try are very useful, though perhaps they should be more prominent and also be available for your own definitions.)
If we're complaining about the lack of improper unicode symbols, even more obvious that set operations are arrows. Too long and too often have programmers written ->, =>, <- and their ilk. And single-equals assignment, and ! for not instead of ≠. Sub- and super scripts would be nice as well, but pretty soon we're writing LaTeX. Agda went the rich unicode route with its emacs-only IDE. It seems pretty abstract and impractical - when Ulf presented at ICFP last year, he implemented the calculus of constructions, which means exactly nothing to the web developers Elm wants to appeal to eventually.But to your idea of IDEs switching between operators - perhaps one could display `Set.union` into ∪ without being too bothersome about it? The official encoding would still be ASCII. The IDE would have to be smart enough to understand import qualification, which vim certainly doesn't, it just does string matching. (If there's a more sophisticated plugin, please let me know.) OTOH, visually replacing ASCII arrows could be pretty easy to do.
(GREEK_SMALL_LETTER_PHI GREEK_SMALL_LETTER_PSI + GREEK_SMALL_LETTER_OMEGA GREEK_SMALL_LETTER_LAMBDA)
is converted to:
(φ ψ + ω λ)
Here's my 2 cents.
I'm a newbie FPer and have just read a few Haskell tutorials. I much prefer elm due to its lack of a million operators.
I have seen <$> used in a lot of Haskell code but I never knew what it meant because it is impossible to Google. I still don't really know but from this discussion it seems like it's the same as $ but lifts the functions as well or something?
This gets much worse when reading code that uses these operators all over the place.
Not to mention I have no name for the operators so I can't "read" the code so much as try to look at it and give names to things myself. It makes learning hard and I come from a math background!
(Another great thing about try elm is the hints on how to read the few operators there are.)
I think brevity shouldn't be at the expense of maintainability.
And calling unfamiliar things "ridiculously cryptic". Seriously? Where are we, the Javascript IRC channel?
Operators are as inherently cryptic as unfamiliar names. If you don't know what a `fold` is, then it doesn't matter whether the operation is called `foldl` or `./`, as you would still need to go through the process of learning the concepts behind that operation (relying on English or any other natural language only gets you so far, and in most cases they lead you in the wrong direction — specially in English since some words are quite overloaded). The overuse of operators (as well as the overuse of unfamiliar words) may lead to programs that are difficult to read, however. I like Evan's guidelines on the naming of operations (http://library.elm-lang.org/DesignGuidelines.html#naming), although I would not be so extreme as to say "avoid operators at all costs".