Skip to content

Commit

Permalink
Add (##) operator to Util.
Browse files Browse the repository at this point in the history
This is just a replacement for (#) from lens.
  • Loading branch information
cchalmers committed Mar 9, 2015
1 parent 5510444 commit 477c88f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Diagrams/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Diagrams.Util
with
, applyAll
, (#)
, (##)

, iterateN

Expand All @@ -27,6 +28,7 @@ module Diagrams.Util

import Data.Default.Class
import Data.Monoid
import Control.Lens hiding (( # ))

-- | Several functions exported by the diagrams library take a number
-- of arguments giving the user control to \"tweak\" various aspects
Expand Down Expand Up @@ -67,6 +69,13 @@ infixl 8 #
(#) :: a -> (a -> b) -> b
(#) = flip ($)

-- | A replacement for lenses' @#@ operator. @(##) = 'review'@.
(##) :: AReview t b -> b -> t
(##) = review
{-# INLINE (##) #-}
infixr 8 ##


-- | @iterateN n f x@ returns the list of the first @n@ iterates of
-- @f@ starting at @x@, that is, the list @[x, f x, f (f x), ...]@
-- of length @n@. (Note that the last element of the list will be
Expand Down

2 comments on commit 477c88f

@bergey
Copy link
Member

@bergey bergey commented on 477c88f Mar 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know that @@ is just flip review, right? I'd still support giving @@ it's most general type. If you think it's important to have both orders, I have no strong objection to ##, though.

@cchalmers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about it. I guess I prefer using ## as a "constructor":

_LineWidth ## 3
3 @@ _LineWidth

Generalising @@ might still be nice.

Please sign in to comment.