diagrams-rubiks-cube 0.2.0.0 → 0.2.0.1
raw patch · 5 files changed
+89/−13 lines, 5 filesdep +adjunctionsdep +distributivedep ~data-default-classdep ~diagrams-libPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: adjunctions, distributive
Dependency ranges changed: data-default-class, diagrams-lib
API changes (from Hackage documentation)
+ Diagrams.RubiksCube.Model: instance Data.Distributive.Distributive Diagrams.RubiksCube.Model.Vec3
+ Diagrams.RubiksCube.Model: instance Data.Distributive.Distributive Diagrams.RubiksCube.Model.Vec4
+ Diagrams.RubiksCube.Model: instance Data.Functor.Rep.Representable Diagrams.RubiksCube.Model.Vec3
+ Diagrams.RubiksCube.Model: instance Data.Functor.Rep.Representable Diagrams.RubiksCube.Model.Vec4
- Diagrams.RubiksCube.Draw: moveSep :: Lens' (MovesSettings n_anXR) n_anXR
+ Diagrams.RubiksCube.Draw: moveSep :: forall n_aBXL. Lens' (MovesSettings n_aBXL) n_aBXL
- Diagrams.RubiksCube.Draw: offsetX :: Lens' (Offsets n_alKn) n_alKn
+ Diagrams.RubiksCube.Draw: offsetX :: forall n_azFx. Lens' (Offsets n_azFx) n_azFx
- Diagrams.RubiksCube.Draw: offsetY :: Lens' (Offsets n_alKn) n_alKn
+ Diagrams.RubiksCube.Draw: offsetY :: forall n_azFx. Lens' (Offsets n_azFx) n_azFx
- Diagrams.RubiksCube.Draw: offsets :: Lens' (MovesSettings n_anXR) (Offsets n_anXR)
+ Diagrams.RubiksCube.Draw: offsets :: forall n_aBXL. Lens' (MovesSettings n_aBXL) (Offsets n_aBXL)
- Diagrams.RubiksCube.Draw: showEnd :: Lens' (MovesSettings n_anXR) Bool
+ Diagrams.RubiksCube.Draw: showEnd :: forall n_aBXL. Lens' (MovesSettings n_aBXL) Bool
- Diagrams.RubiksCube.Draw: showStart :: Lens' (MovesSettings n_anXR) Bool
+ Diagrams.RubiksCube.Draw: showStart :: forall n_aBXL. Lens' (MovesSettings n_aBXL) Bool
- Diagrams.RubiksCube.Model: backSide :: Lens' (Cube a_adOn) a_adOn
+ Diagrams.RubiksCube.Model: backSide :: forall a_afAZ. Lens' (Cube a_afAZ) a_afAZ
- Diagrams.RubiksCube.Model: bottomCenter :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: bottomCenter :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: bottomLeft :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: bottomLeft :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: bottomRight :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: bottomRight :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: cube :: Iso (RubiksCube a_aexx) (RubiksCube a_aeEa) (Cube (Side a_aexx)) (Cube (Side a_aeEa))
+ Diagrams.RubiksCube.Model: cube :: forall a_ageU a_aglv. Iso (RubiksCube a_ageU) (RubiksCube a_aglv) (Cube (Side a_ageU)) (Cube (Side a_aglv))
- Diagrams.RubiksCube.Model: downSide :: Lens' (Cube a_adOn) a_adOn
+ Diagrams.RubiksCube.Model: downSide :: forall a_afAZ. Lens' (Cube a_afAZ) a_afAZ
- Diagrams.RubiksCube.Model: frontSide :: Lens' (Cube a_adOn) a_adOn
+ Diagrams.RubiksCube.Model: frontSide :: forall a_afAZ. Lens' (Cube a_afAZ) a_afAZ
- Diagrams.RubiksCube.Model: leftSide :: Lens' (Cube a_adOn) a_adOn
+ Diagrams.RubiksCube.Model: leftSide :: forall a_afAZ. Lens' (Cube a_afAZ) a_afAZ
- Diagrams.RubiksCube.Model: middleCenter :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: middleCenter :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: middleLeft :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: middleLeft :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: middleRight :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: middleRight :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: rightSide :: Lens' (Cube a_adOn) a_adOn
+ Diagrams.RubiksCube.Model: rightSide :: forall a_afAZ. Lens' (Cube a_afAZ) a_afAZ
- Diagrams.RubiksCube.Model: topCenter :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: topCenter :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: topLeft :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: topLeft :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: topRight :: Lens' (Side a_a9mr) a_a9mr
+ Diagrams.RubiksCube.Model: topRight :: forall a_abFx. Lens' (Side a_abFx) a_abFx
- Diagrams.RubiksCube.Model: upSide :: Lens' (Cube a_adOn) a_adOn
+ Diagrams.RubiksCube.Model: upSide :: forall a_afAZ. Lens' (Cube a_afAZ) a_afAZ
Files
- CHANGELOG.md +4/−0
- README.md +3/−1
- diagrams-rubiks-cube.cabal +6/−4
- src/Diagrams/RubiksCube/Draw.hs +1/−1
- src/Diagrams/RubiksCube/Model.hs +75/−7
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Change Log +## 0.2.0.1 - 2016-10-27++- Updated upper bounds+ ## 0.2.0.0 - 2015-06-01 - Generalized numeric type `n` in `Diagrams.RubiksCube.Draw` (from `Double`)
README.md view
@@ -1,6 +1,6 @@ # diagrams-rubiks-cube -[![Hackage version][hackage-image]][hackage-url] [![Hackage dependencies][hackage-deps-image]][hackage-deps-url] [![Travis Status][travis-image]][travis-url]+[![Hackage version][hackage-image]][hackage-url] [![Hackage dependencies][hackage-deps-image]][hackage-deps-url] [![Travis Status][travis-image]][travis-url] [![Code Climate][codeclimate-image]][codeclimate-url] Haskell library for drawing the Rubik's Cube. @@ -23,3 +23,5 @@ [hackage-url]: http://hackage.haskell.org/package/diagrams-rubiks-cube [hackage-deps-image]: https://img.shields.io/hackage-deps/v/diagrams-rubiks-cube.svg?style=flat [hackage-deps-url]: http://packdeps.haskellers.com/feed?needle=diagrams-rubiks-cube+[codeclimate-url]: https://codeclimate.com/github/timjb/diagrams-rubiks-cube+[codeclimate-image]: https://codeclimate.com/github/timjb/diagrams-rubiks-cube/badges/gpa.svg
diagrams-rubiks-cube.cabal view
@@ -1,5 +1,5 @@ name: diagrams-rubiks-cube-version: 0.2.0.0+version: 0.2.0.1 synopsis: Library for drawing the Rubik's Cube. description: Includes a facets model of the Rubik's Cube and a 'diagrams'-based renderer. homepage: https://github.com/timjb/rubiks-cube@@ -7,7 +7,7 @@ license-file: LICENSE author: Tim Baumann maintainer: tim@timbaumann.info-copyright: 2015 Tim Baumann+copyright: 2015-2016 Tim Baumann category: Graphics build-type: Simple extra-source-files: README.md, CHANGELOG.md, diagrams/*.svg@@ -25,8 +25,10 @@ Diagrams.RubiksCube.Model, Diagrams.RubiksCube.Draw build-depends: base >= 4.6 && < 5,- diagrams-lib >= 1.3 && < 1.4,+ diagrams-lib >= 1.3 && < 1.5, lens >= 4.6.0.1 && < 5,- data-default-class >= 0.0.1 && < 0.1+ data-default-class >= 0.0.1 && < 0.2,+ distributive >= 0.4.4 && < 1,+ adjunctions >= 4.2.1 && < 5 hs-source-dirs: src default-language: Haskell2010
src/Diagrams/RubiksCube/Draw.hs view
@@ -76,7 +76,7 @@ pos :: Int -> Int -> Point V2 n pos x y = P $ fromIntegral x *^ dx ^+^ fromIntegral y *^ dy drawField- :: (RealFloat n, Renderable (Path V2 n) b, N b ~ n, V b ~ V2)+ :: (Renderable (Path V2 n) b, N b ~ n, V b ~ V2) => Int -> Int -> Colour Double -> Diagram b drawField x y color = fromVertices [pos x y, pos (x+1) y, pos (x+1) (y+1), pos x (y+1), pos x y]
src/Diagrams/RubiksCube/Model.hs view
@@ -3,6 +3,10 @@ {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE Rank2Types #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE TypeFamilies #-} module Diagrams.RubiksCube.Model ( -- * Constructing cubes@@ -35,10 +39,39 @@ import Diagrams.RubiksCube.Move (Move (..)) import Data.Foldable (Foldable) import Control.Applicative (Applicative (..), (<$>))+import Data.Distributive (Distributive (..))+import Data.Functor.Rep (Representable (..), distributeRep, tabulated) -- | The type of automorphisms type Aut a = Iso' a a +-- Natural numbers+data N = Z | S N++-- Some type synonyms for natural numbers+type Zero = 'Z+type One = 'S Zero+type Two = 'S One+type Three = 'S Two+type Four = 'S Three++-- | Finite type with n inhabitants+data Fin :: N -> * where+ FinZ :: Fin ('S n)+ FinS :: Fin n -> Fin ('S n)++zero :: Fin ('S n)+zero = FinZ++one :: Fin ('S ('S n))+one = FinS zero++two :: Fin ('S ('S ('S n)))+two = FinS one++three :: Fin ('S ('S ('S ('S n))))+three = FinS two+ -- | A list of fixed length 3. data Vec3 a = Vec3 a a a deriving (Show, Eq, Functor, Foldable, Traversable) @@ -50,6 +83,26 @@ instance Reversing (Vec3 a) where reversing (Vec3 a b c) = Vec3 c b a +instance Distributive Vec3 where+ distribute = distributeRep++instance Representable Vec3 where+ type Rep Vec3 = Fin Three+ tabulate f = Vec3 (f zero) (f one) (f two)+ index (Vec3 a b c) fin =+ case fin of+ FinZ -> a+ FinS FinZ -> b+ FinS (FinS FinZ) -> c+ _ -> error "index@Vec3: cannot happen"++-- | A variant of 'inside' that works for+insideRep+ :: Representable g+ => Lens s t a b+ -> Lens (g s) (g t) (g a) (g b)+insideRep l = from tabulated . inside l . tabulated+ -- | A list of fixed length 4. data Vec4 a = Vec4 a a a a deriving (Show, Eq, Functor, Foldable, Traversable) @@ -58,6 +111,20 @@ Vec4 f1 f2 f3 f4 <*> Vec4 v1 v2 v3 v4 = Vec4 (f1 v1) (f2 v2) (f3 v3) (f4 v4) +instance Distributive Vec4 where+ distribute = distributeRep++instance Representable Vec4 where+ type Rep Vec4 = Fin Four+ tabulate f = Vec4 (f zero) (f one) (f two) (f three)+ index (Vec4 a b c d) fin =+ case fin of+ FinZ -> a+ FinS FinZ -> b+ FinS (FinS FinZ) -> c+ FinS (FinS (FinS FinZ)) -> d+ _ -> error "index@Vec4: cannot happen"+ cycRight :: Vec4 a -> Vec4 a cycRight (Vec4 a b c d) = Vec4 d a b c @@ -274,14 +341,15 @@ type RowsLens a = Lens' (Cube (Side a)) (Vec4 (Vec3 a)) type ColsLens a = Lens' (Cube (Side a)) (Vec4 (Vec3 a)) -horizontalRows :: Lens' (Side a) (Vec3 a) -> RowsLens a-horizontalRows rowLens = lens getter setter+horizontalSides :: Lens' (Cube a) (Vec4 a)+horizontalSides = lens getter setter where- getter (Cube f b l r _u _d) =- fmap (view rowLens) (Vec4 f r b l)- setter (Cube f b l r u d) (Vec4 f' r' b' l') =- Cube (set rowLens f' f) (set rowLens b' b)- (set rowLens l' l) (set rowLens r' r) u d+ getter (Cube f b l r _u _d) = Vec4 f r b l+ setter (Cube _f _b _l _r u d) (Vec4 f' r' b' l') =+ Cube f' b' l' r' u d++horizontalRows :: Lens' (Side a) (Vec3 a) -> RowsLens a+horizontalRows rowLens = horizontalSides . insideRep rowLens upRows :: RowsLens a upRows = horizontalRows topRow