Commit a6983240 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[purescript] upgrade to 0.15, first draft

parent 9de858ae
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,8 +5,8 @@ import ...@@ -5,8 +5,8 @@ import
pkgs.fetchFromGitHub { pkgs.fetchFromGitHub {
owner = "justinwoo"; owner = "justinwoo";
repo = "easy-purescript-nix"; repo = "easy-purescript-nix";
rev = "9c5ffd3e54c41dece66ed84f8f23970a4f1f3883"; rev = "0ad5775c1e80cdd952527db2da969982e39ff592";
sha256 = "8erFzbiRJYqPgJHuQwhgBPltQeaWeAZom/5X3lyUAcc="; sha256 = "bwbpXSTD8Hf7tlCXfZuLfo2QivvX1ZDJ1PijXXRTo3Q=";
} }
) { ) {
inherit pkgs; inherit pkgs;
......
let upstream = let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.7-20220404/packages.dhall sha256:75d0f0719f32456e6bdc3efd41cfc64785655d2b751e3d080bd849033ed053f2 https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220506/packages.dhall sha256:f83b68ff07cf6557e82379e749118e6ff11eecc6be5754540aae855cd1e46917
let overrides = let overrides =
{ globals = { globals =
...@@ -110,15 +110,23 @@ let additions = ...@@ -110,15 +110,23 @@ let additions =
} }
, ffi-simple = , ffi-simple =
{ dependencies = { dependencies =
[ "prelude" [ "aff"
, "arrays"
, "effect" , "effect"
, "maybe" , "foldable-traversable"
, "functions" , "functions"
, "maybe"
, "nullable" , "nullable"
, "prelude"
, "psci-support"
, "refs"
, "spec"
, "tuples"
, "unsafe-coerce" , "unsafe-coerce"
, "unsafe-reference"
] ]
, repo = "https://github.com/irresponsible/purescript-ffi-simple" , repo = "https://github.com/irresponsible/purescript-ffi-simple"
, version = "v0.2.10" , version = "v0.3.0"
} }
, dom-simple = , dom-simple =
{ dependencies = { dependencies =
...@@ -221,7 +229,7 @@ let additions = ...@@ -221,7 +229,7 @@ let additions =
, version = "v2.2.0" , version = "v2.2.0"
} }
, uint = , uint =
{ dependencies = [ "maybe", "math" ] { dependencies = [ "maybe" ]
, repo = "https://github.com/zaquest/purescript-uint" , repo = "https://github.com/zaquest/purescript-uint"
, version = "v5.1.1" , version = "v5.1.1"
} }
......
...@@ -20,10 +20,13 @@ let ...@@ -20,10 +20,13 @@ let
echo "Compiling" echo "Compiling"
#build-purs #build-purs
spago build #spago build
echo "Bundling" #echo "Bundling"
#pulp browserify --skip-compile -t dist/bundle.js --src-path output #pulp browserify --skip-compile -t dist/bundle.js --src-path output
browserify #browserify
# 0.15
spago bundle-app --main Main --to dist/bundle.js
''; '';
...@@ -105,7 +108,7 @@ let ...@@ -105,7 +108,7 @@ let
in in
pkgs.mkShell { pkgs.mkShell {
buildInputs = [ buildInputs = [
easy-ps.purs-0_14_7 easy-ps.purs-0_15_0
easy-ps.psc-package easy-ps.psc-package
easy-ps.dhall-json-simple easy-ps.dhall-json-simple
easy-ps.zephyr easy-ps.zephyr
......
...@@ -49,7 +49,6 @@ to generate this file without the comments in this block. ...@@ -49,7 +49,6 @@ to generate this file without the comments in this block.
, "lists" , "lists"
, "markdown" , "markdown"
, "markdown-smolder" , "markdown-smolder"
, "math"
, "maybe" , "maybe"
, "media-types" , "media-types"
, "milkis" , "milkis"
......
...@@ -9,6 +9,7 @@ import Data.Int (toNumber) ...@@ -9,6 +9,7 @@ import Data.Int (toNumber)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), fromJust) import Data.Maybe (Maybe(..), fromJust)
import Data.Nullable (null, Nullable) import Data.Nullable (null, Nullable)
import Data.Number as DN
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
...@@ -33,7 +34,6 @@ import Gargantext.Types as Types ...@@ -33,7 +34,6 @@ import Gargantext.Types as Types
import Gargantext.Utils ((?)) import Gargantext.Utils ((?))
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Math as Math
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -287,7 +287,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges} ...@@ -287,7 +287,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
, hidden : false , hidden : false
, id : n.id_ , id : n.id_
, label : n.label , label : n.label
, size : Math.log (toNumber n.size + 1.0) , size : DN.log (toNumber n.size + 1.0)
, type : modeGraphType gargType , type : modeGraphType gargType
, x : n.x -- cos (toNumber i) , x : n.x -- cos (toNumber i)
, y : n.y -- sin (toNumber i) , y : n.y -- sin (toNumber i)
......
...@@ -13,6 +13,7 @@ import Data.Foldable as F ...@@ -13,6 +13,7 @@ import Data.Foldable as F
import Data.Int (fromString) import Data.Int (fromString)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), fromJust) import Data.Maybe (Maybe(..), fromJust)
import Data.Number as DN
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
...@@ -38,7 +39,6 @@ import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(.. ...@@ -38,7 +39,6 @@ import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..
import Gargantext.Utils (nbsp) import Gargantext.Utils (nbsp)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Math as Math
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -359,9 +359,9 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -359,9 +359,9 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
-- Computed -- Computed
let let
minSize = F.foldl Math.min 0.0 (Seq.map _.size (SigmaxT.graphNodes graph')) minSize = F.foldl DN.min 0.0 (Seq.map _.size (SigmaxT.graphNodes graph'))
maxSize = F.foldl Math.max 0.0 (Seq.map _.size (SigmaxT.graphNodes graph')) maxSize = F.foldl DN.max 0.0 (Seq.map _.size (SigmaxT.graphNodes graph'))
maxTruncateResult = 5 maxTruncateResult = 5
...@@ -522,7 +522,7 @@ badgeSize minSize maxSize size = ...@@ -522,7 +522,7 @@ badgeSize minSize maxSize size =
minFontSize = 10.0 minFontSize = 10.0
maxFontSize = 24.0 maxFontSize = 24.0
sizeScaled = (size - minSize) / (maxSize - minSize) -- in [0; 1] range sizeScaled = (size - minSize) / (maxSize - minSize) -- in [0; 1] range
scale' = Math.log (sizeScaled + 1.0) / (Math.log 2.0) -- in [0; 1] range scale' = DN.log (sizeScaled + 1.0) / (DN.log 2.0) -- in [0; 1] range
scale = minFontSize + scale' * (maxFontSize - minFontSize) scale = minFontSize + scale' * (maxFontSize - minFontSize)
in in
......
...@@ -42,7 +42,6 @@ import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(.. ...@@ -42,7 +42,6 @@ import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..
import Gargantext.Utils (getter, nbsp) import Gargantext.Utils (getter, nbsp)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Math as Math
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
......
...@@ -10,6 +10,7 @@ import Data.Generic.Rep (class Generic) ...@@ -10,6 +10,7 @@ import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Int (fromNumber) import Data.Int (fromNumber)
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Number as DN
import Data.Nullable (Nullable, null) import Data.Nullable (Nullable, null)
import Data.Traversable (traverse_) import Data.Traversable (traverse_)
import DOM.Simple as DOM import DOM.Simple as DOM
...@@ -19,7 +20,6 @@ import DOM.Simple.EventListener as EL ...@@ -19,7 +20,6 @@ import DOM.Simple.EventListener as EL
import DOM.Simple (DOMRect) import DOM.Simple (DOMRect)
import Global (toFixed) import Global (toFixed)
import Effect (Effect) import Effect (Effect)
import Math as M
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
...@@ -65,7 +65,7 @@ rangeSliderCpt = here.component "rangeSlider" cpt ...@@ -65,7 +65,7 @@ rangeSliderCpt = here.component "rangeSlider" cpt
where where
cpt props _ = do cpt props _ = do
-- rounding precision (i.e. how many decimal digits are in epsilon) -- rounding precision (i.e. how many decimal digits are in epsilon)
let precision = fromMaybe 0 $ fromNumber $ max 0.0 $ - M.floor $ (M.log props.epsilon) / M.ln10 let precision = fromMaybe 0 $ fromNumber $ max 0.0 $ - DN.floor $ (DN.log props.epsilon) / DN.ln10
-- scale bar -- scale bar
scaleElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- dom ref scaleElem <- (R.useRef null) :: R.Hooks (R.Ref (Nullable DOM.Element)) -- dom ref
......
...@@ -11,7 +11,6 @@ import Data.Maybe (Maybe(..)) ...@@ -11,7 +11,6 @@ import Data.Maybe (Maybe(..))
import Data.Ord as Ord import Data.Ord as Ord
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2) import Effect.Uncurried (EffectFn2, runEffectFn2)
import Math as Math
import Gargantext.Prelude import Gargantext.Prelude
...@@ -37,4 +36,4 @@ min xs = foldr reducer (A.head xs) xs ...@@ -37,4 +36,4 @@ min xs = foldr reducer (A.head xs) xs
range :: Int -> Int -> Int -> Array Int range :: Int -> Int -> Int -> Array Int
range start end step = map (\i -> start + i*step) $ A.range 0 end' range start end step = map (\i -> start + i*step) $ A.range 0 end'
where where
end' = DI.round $ Math.floor $ (DI.toNumber $ end - start) / (DI.toNumber step) end' = DI.round $ DI.floor $ (DI.toNumber $ end - start) / (DI.toNumber step)
module Gargantext.Utils.Math where module Gargantext.Utils.Math where
import Data.Number as DN
import Prelude import Prelude
import Math as Math
roundToMultiple :: Number -> Number -> Number roundToMultiple :: Number -> Number -> Number
roundToMultiple eps num = eps * Math.round (num / eps) roundToMultiple eps num = eps * DN.round (num / eps)
-- | Logarithm with given base -- | Logarithm with given base
logb :: Number -> Number -> Number logb :: Number -> Number -> Number
logb base n = (Math.log n) / (Math.log base) logb base n = (DN.log n) / (DN.log base)
log10 :: Number -> Number log10 :: Number -> Number
log10 = logb 10.0 log10 = logb 10.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment