Giter VIP home page Giter VIP logo

core's Introduction

Core Libraries

Every Gren project needs this package!

It provides basic functionality like addition and subtraction as well as data structures like arrays, dictionaries, and sets.

New to Gren? Go to gren-lang.org for an overview.

Default Imports

The modules in this package are so common, that some of them are imported by default in all Gren files. So it is as if every Gren file starts with these imports:

import Basics exposing (..)
import Array exposing (Array)
import Maybe exposing (Maybe(..))
import Result exposing (Result(..))
import String exposing (String)
import Char exposing (Char)

import Debug

import Platform exposing (Program)
import Platform.Cmd as Cmd exposing (Cmd)
import Platform.Sub as Sub exposing (Sub)

The intention is to include things that are both extremely useful and very unlikely to overlap with anything that anyone will ever write in a library. By keeping the set of default imports relatively small, it also becomes easier to use whatever version of map suits your fancy. Finally, it makes it easier to figure out where the heck a function is coming from.

core's People

Contributors

alexislozano avatar arkham avatar avh4 avatar blaix avatar dandandan avatar deadfoxygrandpa avatar eeue56 avatar evancz avatar harrysarson avatar hossameldeen avatar imeckler avatar jazmit avatar jcollard avatar jerith666 avatar jonathanhefner avatar jonathanperret avatar jvoigtlaender avatar jwmerrill avatar laszlopandy avatar lorenzo avatar mariosangiorgio avatar maxsnew avatar mgold avatar noahzgordon avatar process-bot avatar rgrempel avatar rluiten avatar robinheghan avatar simonh1000 avatar turbomack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

core's Issues

Core still imports Tuple

If I recall correctly, one difference of gren from elm is to not use tuples, but records instead.

prefix binary operations → curry-able functions

Using an operator's prefix notation is unintuitive and prone to errors:

Just 3 |> Maybe.map ((-) 3)
--> Just 0

Proposal: remove (symbol) syntax and prefix binary operations in favor of actual functions:

  • (^) n expn |> toPower exp
  • (/) n divn |> divideBy div
  • (//) n divn |> Int.divideBy div
  • (*) n muln |> multiplyBy mul
  • (-) n subn |> subtract sub
  • (+) a bb |> add a
  • ...
  • bool |> and also
  • bool |> or also
  • min a ba |> atMost b
  • max a ba |> atLeast b
  • (<) a ba |> isBelow b
  • (<=) a ba |> isAtMost b
  • (>=) a ba |> isAtLeast b
  • (>) a ba |> isAbove b
  • (++) init tail, .append init tailinit |> .append tail
  • (::) element listlist |> cons element
  • (<|)apply? remove?
  • (|>)eat/feed/feedWith/with? remove?
  • (>>) → remove?
  • (<<)over/overTo/to/then/thenTo/compose/furthermore/furtherTo? remove?

including parser operators (replaced by |> skip, |> grab, ...).

My secret hope is that just like %, which was removed in favor of modBy & remainderBy,
conventions will develop abandoning, for example

  • &&, ||, min, max, unary -, ^, all parser operators
  • init |> append middle |> append tail
    > [ init, middle |> operation, tail ] |> concat
    > init ++ (middle |> operation) ++ tail

(I'm not opposed to removing all listed and more)

Comparing Arrays will crash

It seems like there is issues comparing Arrays. ( This also makes using Array as key for Dict crash )

This thing compiles:
image

But crashes in the browser:
image

Could it be some "cons" logic from Elm-lists that does not work for arrays?
image

Provide direct access to JS Strings

Gren currently abstracts away the fact that JavaScript Strings uses a 16-bit encoding, and performs runtime conversion between different representations in an attempt to make Strings and Characters easier to understand.

This abstraction isn't free however. The current implementation has bugs and performance implications. Certain code, like String hashing, becomes harder to do well because it's sometimes necessary to undo the runtime conversions that the Gren runtime performs.

It might be better to simply remove this abstraction, so that Gren strings are JS strings, with all the benefits and downsides that entail.

Pros:

  • Simpler maintance
  • Improved performance
  • One less abstraction to worry about when dealing with strings

Cons:

  • Users, especially those who don't already know JS, might find strings harder to reason about.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.