Giter Site home page Giter Site logo

Comments (6)

dotnetCarpenter avatar dotnetCarpenter commented on August 15, 2024

This definitely need a StrMap ({...props}) constructor. It is already cumbersome to work with other libraries and being even stricter will not make it less cumbersome. However, if this makes the code base leaner and improve error messages, I am all for it.

But please make it simple to convert a foreign object to a StrMap.

from sanctuary.

davidchambers avatar davidchambers commented on August 15, 2024

I like this idea!

How would we describe the type of the data constructor?

StrMap :: ??? -> StrMap a

Would S.StrMap ({x: 'abc', y: 123}) throw an exception when evaluated?

from sanctuary.

dotnetCarpenter avatar dotnetCarpenter commented on August 15, 2024

I vote for a way to convert all properties to String but S.Left in the normal case. My thinking is that this might be wrong input that I need to handle but when I have made certain it is not, let me get a StrMap String.

You often get a foreign object such as:

{
  fill: '#f06'
, 'fill-opacity': 0.5
, stroke: '#000'
, 'stroke-width': 10
}

from sanctuary.

davidchambers avatar davidchambers commented on August 15, 2024

@dotnetCarpenter, are you suggesting that the data constructor's return type should be Either String (StrMap a) or Either Error (StrMap a) rather than StrMap a?

from sanctuary.

Avaq avatar Avaq commented on August 15, 2024

Would S.StrMap ({x: 'abc', y: 123}) throw an exception when evaluated?

It might be fine just to have it return a mixed-type StrMap. It's possible to work with mixed-type StrMaps outside of Sanctuary, or using S.unchecked.

from sanctuary.

Avaq avatar Avaq commented on August 15, 2024

It's just like the Array constructor; We allow users to do ['abc', 123], but then it's checked for consistency when this value is passed into a Sanctuary function.

from sanctuary.

Related Issues (20)

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.