Skip to content

Commit

Permalink
Use purescript-isometric, PS 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Aug 7, 2016
1 parent 339af60 commit a64c898
Show file tree
Hide file tree
Showing 29 changed files with 173 additions and 355 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
bower_components
.psci
.psci_modules
.pulp-cache
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![cube composer](https://raw.githubusercontent.com/sharkdp/cube-composer/master/img/cube-composer.png)

A puzzle game inspired by functional programming.
It is written in [PureScript](https://github.com/purescript/purescript) and uses [Isomer.js](https://github.com/jdan/isomer) for the canvas rendering.
A puzzle game inspired by functional programming,
written in [PureScript](https://github.com/purescript/purescript).

[**Play it online!**](http://david-peter.de/cube-composer)

Expand Down
24 changes: 12 additions & 12 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"bower_components"
],
"dependencies": {
"purescript-arrays": "^0.4.0",
"purescript-console": "^0.1.0",
"purescript-dom": "^0.2.7",
"purescript-enums": "^0.7.0",
"purescript-foldable-traversable": "^0.4.0",
"purescript-integers": "^0.2.0",
"purescript-maps": "^0.5.0",
"purescript-math": "^0.2.0",
"purescript-nullable": "^0.2.1",
"purescript-strings": "^0.7.0",
"Sortable": "RubaXa/Sortable#~1.3.0",
"isomer": "https://github.com/jdan/isomer.git#fbd7b9e86e542f482f94718d8fbf7f597c14a14d"
"purescript-arrays": "^1.1.0",
"purescript-console": "^1.0.0",
"purescript-dom": "^2.0.0",
"purescript-enums": "^1.0.0",
"purescript-foldable-traversable": "^1.0.0",
"purescript-integers": "^1.1.0",
"purescript-maps": "^1.1.0",
"purescript-math": "^2.0.0",
"purescript-nullable": "^1.0.0",
"purescript-strings": "^1.1.0",
"purescript-isometric": "^1.0.0",
"Sortable": "RubaXa/Sortable#~1.4.0"
}
}
4 changes: 0 additions & 4 deletions docs/Helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Operator to create tuples, especially for creating maps with
infixl 6 tuple as :>
```

_left-associative / precedence 6_

#### `AStack`

``` purescript
Expand Down Expand Up @@ -69,6 +67,4 @@ Helper function to create levels from arrays of cubes (instead of lists)
infixl 6 level as :->
```

_left-associative / precedence 6_


69 changes: 0 additions & 69 deletions docs/Isomer.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Sortable.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#### `installSortable`

``` purescript
installSortable :: forall eff. Element -> Eff (dom :: DOM | eff) Unit -> Eff (dom :: DOM | eff) Unit
installSortable :: forall eff. Element -> (Eff (dom :: DOM | eff) Unit) -> Eff (dom :: DOM | eff) Unit
```

Install 'Sortable' on the given DOM element. The second argument is
Expand Down
2 changes: 1 addition & 1 deletion docs/Storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fromSaveable :: SaveableGameState -> GameState
#### `unsafeLoadGameState`

``` purescript
unsafeLoadGameState :: forall a eff. (a -> Maybe a) -> Maybe a -> Eff (storage :: STORAGE | eff) (Maybe SaveableGameState)
unsafeLoadGameState :: forall a eff. (a -> Maybe a) -> (Maybe a) -> Eff (storage :: STORAGE | eff) (Maybe SaveableGameState)
```

Retrieve the current game state from local storage (FFI, needs 'Just' and 'Nothing' as input)
Expand Down
1 change: 1 addition & 0 deletions docs/Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Eq Cube
Ord Cube
Bounded Cube
Enum Cube
BoundedEnum Cube
```

#### `Stack`
Expand Down
2 changes: 0 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ gulp.task("less", function() {
gulp.task("concat", ["bundle"], function() {
return gulp.src([
"bower_components/Sortable/Sortable.min.js",
"bower_components/isomer/dist/isomer.min.js",
"dist/main.js"
])
.pipe(concat("main.js"))
Expand All @@ -110,7 +109,6 @@ gulp.task("docs", ["clean-docs"], function () {
docgen: {
"DOMHelper": "docs/DOMHelper.md",
"Helper": "docs/Helper.md",
"Isomer": "docs/Isomer.md",
"Levels": "docs/Levels.md",
"Sortable": "docs/Sortable.md",
"Storage": "docs/Storage.md",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"gulp": "^3.9.0",
"gulp-concat": "^2.5.2",
"gulp-less": "^3.0.3",
"gulp-purescript": "^0.8.0",
"gulp-purescript": "^1.0.0",
"gulp-uglify": "^1.2.0",
"rimraf": "^2.4.0"
}
Expand Down
2 changes: 0 additions & 2 deletions src/Foreign/Analytics.js → src/Analytics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// module Analytics

exports.analyticsEvent = function(category) {
return function(action) {
return function(label) {
Expand Down
2 changes: 0 additions & 2 deletions src/Foreign/DOMHelper.js → src/DOMHelper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// module DOMHelper

exports.getSelectedValue = function (src) {
return function() {
return src.options[src.selectedIndex].value;
Expand Down
16 changes: 8 additions & 8 deletions src/DOMHelper.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import DOM.Node.NonElementParentNode (getElementById)
import DOM.Node.ParentNode (children)
import DOM.Node.Types (HTMLCollection(), Element(), Document(), ElementId(..),
documentToNonElementParentNode, elementToParentNode)
import Data.Either.Unsafe (fromRight)
import Data.Either (fromRight)
import Data.Foreign (toForeign)
import Data.Maybe (Maybe(), maybe)
import Data.Maybe.Unsafe (fromJust)
import Data.Maybe (Maybe(), maybe, fromJust)
import Data.Nullable (toMaybe)
import Partial.Unsafe (unsafePartial)

getDocument :: forall eff. Eff (dom :: DOM | eff) Document
getDocument = window >>= document <#> htmlDocumentToDocument
Expand All @@ -28,14 +28,14 @@ getElementById' :: forall eff. String
getElementById' id doc = do
let docNode = documentToNonElementParentNode doc
nullableEl <- getElementById (ElementId id) docNode
return $ toMaybe nullableEl
pure $ toMaybe nullableEl

-- | Perform a DOM action with a single element which can be accessed by ID
withElementById :: forall eff. String
-> Document
-> (Element -> Eff (dom :: DOM | eff) Unit)
-> Eff (dom :: DOM | eff) Unit
withElementById id doc action = getElementById' id doc >>= maybe (return unit) action
withElementById id doc action = getElementById' id doc >>= maybe (pure unit) action

children' :: forall eff. Element -> Eff (dom :: DOM | eff) (Array HTMLElement)
children' el = htmlCollectionToArray <$> children (elementToParentNode el)
Expand All @@ -45,13 +45,13 @@ addEventListener' etype listener target =
addEventListener etype (eventListener listener) true target

unsafeElementToHTMLElement :: Element -> HTMLElement
unsafeElementToHTMLElement = fromRight <<< readHTMLElement <<< toForeign
unsafeElementToHTMLElement = unsafePartial (fromRight <<< readHTMLElement <<< toForeign)

unsafeEventToKeyboardEvent :: Event -> KeyboardEvent
unsafeEventToKeyboardEvent = fromRight <<< readKeyboardEvent <<< toForeign
unsafeEventToKeyboardEvent = unsafePartial (fromRight <<< readKeyboardEvent <<< toForeign)

unsafeGetAttribute :: forall eff. String -> Element -> Eff (dom :: DOM | eff) String
unsafeGetAttribute key el = (fromJust <<< toMaybe) <$> getAttribute key el
unsafeGetAttribute key el = unsafePartial (fromJust <<< toMaybe) <$> getAttribute key el

foreign import getSelectedValue :: forall eff. Element
-> Eff (dom :: DOM | eff) String
Expand Down
46 changes: 0 additions & 46 deletions src/Foreign/Isomer.js

This file was deleted.

8 changes: 4 additions & 4 deletions src/Helper.purs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module Helper where

import Prelude
import Data.List (toList)
import Data.List (fromFoldable)
import Data.Maybe (Maybe)
import Data.Tuple (Tuple(..))
import Data.StrMap as SM

import Types
import Types (Level, LevelId, Difficulty, Wall, Cube)

-- | Create a StrMap from an Array of (key, value) pairs
fromArray :: forall a. Array (Tuple String a) -> SM.StrMap a
fromArray = SM.fromList <<< toList
fromArray = SM.fromList <<< fromFoldable

-- | Operator to create tuples, especially for creating maps with
-- | `Map.fromList ["key1" :> "value1", "key2" :> "value2"]`
Expand All @@ -25,7 +25,7 @@ type AWall = Array AStack

-- | Convert 2D Array to List
convert :: AWall -> Wall
convert = toList <<< map toList
convert = fromFoldable <<< map fromFoldable

-- | Helper type to create levels from arrays
type LevelEntry = {
Expand Down
70 changes: 0 additions & 70 deletions src/Isomer.purs

This file was deleted.

Loading

0 comments on commit a64c898

Please sign in to comment.