seperate haskell und purescript directories
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/.pulp-cache/
|
||||
/output/
|
||||
/generated-docs/
|
||||
/.psc-package/
|
||||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago
|
||||
/index.js
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build_purescript",
|
||||
"type": "shell",
|
||||
"command": "spago bundle-app && uglifyj s index.js --compress --mangle --output index.js",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "build_purescript_old",
|
||||
"type": "shell",
|
||||
"command": "spago bundle-app && sed -i \"$ d\" index.js && uglifyjs index.js --compress --mangle --output index.js",
|
||||
"group": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
{-
|
||||
Welcome to your new Dhall package-set!
|
||||
|
||||
Below are instructions for how to edit this file for most use
|
||||
cases, so that you don't need to know Dhall to use it.
|
||||
|
||||
## Warning: Don't Move This Top-Level Comment!
|
||||
|
||||
Due to how `dhall format` currently works, this comment's
|
||||
instructions cannot appear near corresponding sections below
|
||||
because `dhall format` will delete the comment. However,
|
||||
it will not delete a top-level comment like this one.
|
||||
|
||||
## Use Cases
|
||||
|
||||
Most will want to do one or both of these options:
|
||||
1. Override/Patch a package's dependency
|
||||
2. Add a package not already in the default package set
|
||||
|
||||
This file will continue to work whether you use one or both options.
|
||||
Instructions for each option are explained below.
|
||||
|
||||
### Overriding/Patching a package
|
||||
|
||||
Purpose:
|
||||
- Change a package's dependency to a newer/older release than the
|
||||
default package set's release
|
||||
- Use your own modified version of some dependency that may
|
||||
include new API, changed API, removed API by
|
||||
using your custom git repo of the library rather than
|
||||
the package set's repo
|
||||
|
||||
Syntax:
|
||||
Replace the overrides' "{=}" (an empty record) with the following idea
|
||||
The "//" or "⫽" means "merge these two records and
|
||||
when they have the same value, use the one on the right:"
|
||||
-------------------------------
|
||||
let overrides =
|
||||
{ packageName =
|
||||
upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" }
|
||||
, packageName =
|
||||
upstream.packageName // { version = "v4.0.0" }
|
||||
, packageName =
|
||||
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" }
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
Example:
|
||||
-------------------------------
|
||||
let overrides =
|
||||
{ halogen =
|
||||
upstream.halogen // { version = "master" }
|
||||
, halogen-vdom =
|
||||
upstream.halogen-vdom // { version = "v4.0.0" }
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
### Additions
|
||||
|
||||
Purpose:
|
||||
- Add packages that aren't already included in the default package set
|
||||
|
||||
Syntax:
|
||||
Replace the additions' "{=}" (an empty record) with the following idea:
|
||||
-------------------------------
|
||||
let additions =
|
||||
{ package-name =
|
||||
{ dependencies =
|
||||
[ "dependency1"
|
||||
, "dependency2"
|
||||
]
|
||||
, repo =
|
||||
"https://example.com/path/to/git/repo.git"
|
||||
, version =
|
||||
"tag ('v4.0.0') or branch ('master')"
|
||||
}
|
||||
, package-name =
|
||||
{ dependencies =
|
||||
[ "dependency1"
|
||||
, "dependency2"
|
||||
]
|
||||
, repo =
|
||||
"https://example.com/path/to/git/repo.git"
|
||||
, version =
|
||||
"tag ('v4.0.0') or branch ('master')"
|
||||
}
|
||||
, etc.
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
Example:
|
||||
-------------------------------
|
||||
let additions =
|
||||
{ benchotron =
|
||||
{ dependencies =
|
||||
[ "arrays"
|
||||
, "exists"
|
||||
, "profunctor"
|
||||
, "strings"
|
||||
, "quickcheck"
|
||||
, "lcg"
|
||||
, "transformers"
|
||||
, "foldable-traversable"
|
||||
, "exceptions"
|
||||
, "node-fs"
|
||||
, "node-buffer"
|
||||
, "node-readline"
|
||||
, "datetime"
|
||||
, "now"
|
||||
]
|
||||
, repo =
|
||||
"https://github.com/hdgarrood/purescript-benchotron.git"
|
||||
, version =
|
||||
"v7.0.0"
|
||||
}
|
||||
}
|
||||
-------------------------------
|
||||
-}
|
||||
|
||||
|
||||
let upstream =
|
||||
https://github.com/purescript/package-sets/releases/download/psc-0.13.6-20200404/packages.dhall sha256:f239f2e215d0cbd5c203307701748581938f74c4c78f4aeffa32c11c131ef7b6
|
||||
|
||||
let overrides = {=}
|
||||
|
||||
let additions = {=}
|
||||
|
||||
in upstream // overrides // additions
|
||||
@@ -0,0 +1,17 @@
|
||||
{-
|
||||
Welcome to a Spago project!
|
||||
You can edit this file as you like.
|
||||
-}
|
||||
{ name = "shadown_of_the_knight"
|
||||
, dependencies =
|
||||
[ "arrays"
|
||||
, "console"
|
||||
, "effect"
|
||||
, "integers"
|
||||
, "math"
|
||||
, "psci-support"
|
||||
, "random"
|
||||
]
|
||||
, packages = ./packages.dhall
|
||||
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
module Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Array (filter, head, length, reverse, sort, sortBy, (!!), (..))
|
||||
import Data.Int (fromNumber, toNumber)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Effect (Effect)
|
||||
import Effect.Console (error, log)
|
||||
import Math as M
|
||||
import Range (Range(..), Area(..), Pos(..), range)
|
||||
import Reader (GameInput, parseInput, readline)
|
||||
|
||||
main :: Effect Unit
|
||||
main = do
|
||||
input <- parseInput
|
||||
error $ show input
|
||||
loop input (calcArea input)
|
||||
|
||||
calcArea :: GameInput -> Area
|
||||
calcArea input = Area rX rY
|
||||
where
|
||||
rX = range 0 $ input.width - 1
|
||||
rY = range 0 $ input.height - 1
|
||||
|
||||
loop :: GameInput -> Area -> Effect Unit
|
||||
loop input area = do
|
||||
dir <- readline
|
||||
|
||||
let pos = Pos input.x input.y
|
||||
|
||||
let area' = shrinkArea dir area pos
|
||||
error $ show area
|
||||
error $ show area'
|
||||
let (Pos x y) = getMiddlePos area'
|
||||
let input' = input { x = x, y = y }
|
||||
|
||||
log $ show x <> " " <> show y
|
||||
|
||||
loop input' area'
|
||||
|
||||
where
|
||||
shrinkArea :: String -> Area -> Pos -> Area
|
||||
shrinkArea "U" a (Pos x y) = Area (range x x) (yUp a y)
|
||||
shrinkArea "D" a (Pos x y) = Area (range x x) (yDown a y)
|
||||
shrinkArea "R" a (Pos x y) = Area (xRight a x) (range y y)
|
||||
shrinkArea "L" a (Pos x y) = Area (xLeft a x) (range y y)
|
||||
shrinkArea "UR" a (Pos x y) = Area (xRight a x) (yUp a y)
|
||||
shrinkArea "DR" a (Pos x y) = Area (xRight a x) (yDown a y)
|
||||
shrinkArea "DL" a (Pos x y) = Area (xLeft a x) (yDown a y)
|
||||
shrinkArea "UL" a (Pos x y) = Area (xLeft a x) (yUp a y)
|
||||
shrinkArea _ _ _ = Area (range 9999 9999) (range 9999 9999)
|
||||
xRight (Area (Range xL xR) _) x = range (x+1) xR
|
||||
xLeft (Area (Range xL xR) _) x = range xL (x-1)
|
||||
yUp (Area _ (Range yU yL)) y = range yU (y-1)
|
||||
yDown (Area _ (Range yU yL)) y = range (y+1) yL
|
||||
|
||||
maxPos :: Pos -> Int
|
||||
maxPos (Pos x y) = max x y
|
||||
|
||||
minPos :: Pos -> Int
|
||||
minPos (Pos x y) = min x y
|
||||
|
||||
getMiddlePos :: Area -> Pos
|
||||
getMiddlePos (Area (Range x1 x2) (Range y1 y2)) = Pos x y
|
||||
where
|
||||
x = abs (x1 + x2) / 2
|
||||
y = abs (y1 + y2) / 2
|
||||
|
||||
abs :: Int -> Int
|
||||
abs x = fromMaybe (-1) $ fromNumber $ M.abs $ toNumber x
|
||||
@@ -0,0 +1,26 @@
|
||||
module Range
|
||||
( Area(..)
|
||||
, Pos(..)
|
||||
, Range(..)
|
||||
, range
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
|
||||
-- data Building = Building Int Int
|
||||
data Pos = Pos Int Int
|
||||
data Area = Area Range Range
|
||||
|
||||
instance showPos :: Show Pos where
|
||||
show (Pos x y) = show x <> " " <> show y
|
||||
|
||||
instance showRange :: Show Range where
|
||||
show (Range x y) = show x <> "-" <> show y
|
||||
|
||||
instance showArea :: Show Area where
|
||||
show (Area r1 r2) = show r1 <> " / " <> show r2
|
||||
|
||||
data Range = Range Int Int
|
||||
|
||||
range :: Int -> Int -> Range
|
||||
range x y = Range (min x y) (max x y)
|
||||
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
exports.readline = readline
|
||||
|
||||
exports.parseInput = function() {
|
||||
var inputs = readline().split(' ');
|
||||
var W = parseInt(inputs[0]); // width of the building.
|
||||
var H = parseInt(inputs[1]); // height of the building.
|
||||
var N = parseInt(readline()); // maximum number of turns before game over.
|
||||
var inputs = readline().split(' ');
|
||||
var X0 = parseInt(inputs[0]);
|
||||
var Y0 = parseInt(inputs[1]);
|
||||
return {
|
||||
width: W,
|
||||
height: H,
|
||||
turns: N,
|
||||
x: X0,
|
||||
y: Y0,
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
module Reader where
|
||||
|
||||
import Effect (Effect)
|
||||
|
||||
type GameInput =
|
||||
{ width :: Int
|
||||
, height :: Int
|
||||
, turns :: Int
|
||||
, x :: Int
|
||||
, y :: Int
|
||||
}
|
||||
|
||||
foreign import parseInput :: Effect GameInput
|
||||
|
||||
foreign import readline :: Effect String
|
||||
@@ -0,0 +1,19 @@
|
||||
module Test.Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Effect (Effect)
|
||||
import Effect.Console (log)
|
||||
|
||||
|
||||
main :: Effect Unit
|
||||
main = do
|
||||
let input = {
|
||||
x: 20,
|
||||
y: 20,
|
||||
width: 100,
|
||||
height: 100,
|
||||
turns: 50
|
||||
}
|
||||
-- loop input $ calcWindows input
|
||||
log "hi"
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user