connectPerim' Haskell Diagrams function

94 views Asked by At

I have found some problems with connectPerim' function in Haskell Diagrams. This function connects perimeters of two figures in selected parts of perimeters (this time figures perimeter is divided into 12 parts and the number before "/" means which part is selected to connect). connectPerim' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Angle -> Angle -> Diagram b R2 -> Diagram b R2 For example:

# connectPerim' singleHeadArrow "2" "1" (6/12 :: Turn) (0/12 :: Turn)

I would like to put both Angle parameters ((6/12 :: Turn) and (0/12 :: Turn)) into new variable, but I am able only to put those parameters into separate variables. for example

arrowRight1 = (6/12 :: Turn)
arrowRight2 = (0/12 :: Turn)
# connectPerim' singleHeadArrow "2" "1" arrowRight1 arrowRight2

Is it possible to combine those Angle parameters to one variable? If it is could You give an example? Thank You in advance!

1

There are 1 answers

0
Benesh On

You can create an alternative version of connectPerim' which accepts two angles as a single tuple:

connectPerim'' ao n1 n2 (a0,a1) = connectPerim' ao n1 n2 a0 a1

An equivalent and more elegant definition, using uncurry:

connectPerim'' ao n1 n2 = uncurry $ connectPerim' ao n1 n2

Usage:

let arrowRight = (6/12,0/12) :: (Turn, Turn)
in connectPerim'' singleHeadArrow "2" "1" arrowRight