Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Álvaro Touzón
@kasselTrankos
i put the def, if can help
const $Sum = $.UnaryType
('Sum')
('http://example.com/my-package#Sum')
([])
(x => type(x) === 'my/sum@1')
(({value}) => [value] )

const $Tuple = $.BinaryType
  ('Tuple')
  ('http://example.com/my-package#Tuple')
  ([])
  (x => type(x) === 'my/tuple@1')
  ( ({fst}) => [fst] )
  ( ({snd}) => [snd] )
const S = create ({checkTypes: true, env: env.concat( [ 
  $Sum ($.ValidNumber),
  $Tuple ($.Unknown) ($.Unknown),
] )})
David Chambers
@davidchambers
:point_up: This looks right. Did it work, @kasselTrankos?
Álvaro Touzón
@kasselTrankos
yes
i think why
David Chambers
@davidchambers
That's good!
Álvaro Touzón
@kasselTrankos
i’ll try to explain
in the tuple.js
file when i made concat
i got this
function Tuple$prototype$concat(that) {
  console.log('TUPLE', this, that, type(that), type(that.fst), 'hola', type(that.fst)) //S.concat (this.fst) (that.fst))
    return Tuple( S.concat (this.fst) (that.fst) ) (S.concat ( this.snd) (that.snd) )
}
using S.concat
is not able
becose the S, is not the same S that made in the other code
so it hasnt the new Types
will be?
@davidchambers
David Chambers
@davidchambers
I suggest using Z (sanctuary-type-classes) rather than S when implementing your own algebraic data types. That way you can avoid a chicken-and-egg situation.
Álvaro Touzón
@kasselTrankos
ok, ill study, i read the pair implementation and saw it use
David Chambers
@davidchambers

Before:

S.concat (this.fst) (that.fst)

After:

Z.concat (this.fst, that.fst)
Álvaro Touzón
@kasselTrankos
yes,
works, as i see Z dont check the types?
ill read anyway
thanks @davidchambers
David Chambers
@davidchambers
That's right. Z functions do no type checking.
Álvaro Touzón
@kasselTrankos
thanks is runing :)
Álvaro Touzón
@kasselTrankos
first sorry for made a lot of questions, and in other hand THANKS
one more question
It will be able to add traversable to a Tuple
i think is able, and im finding a way to resolve, so any help ?
or if im in a wrong case of use of a Tuple
thanks again
David Chambers
@davidchambers
See Pair#fantasy-land/traverse, @kasselTrankos.
Álvaro Touzón
@kasselTrankos
yes i studied it before, but in this case the function apply to both ( fst, snd)?
the same function?
the main idea is to reconstruct Tuple by its self
so i think using bimap, as same way use map in PAir
David Chambers
@davidchambers
@silly-goat
S.traverse
silly-goat
@silly-goat
traverse :: (Applicative f, Traversable t) => TypeRep (f b) -> (a -> f b) -> t a -> f (t b)
David Chambers
@davidchambers
:point_up: How do you intend this to work for your type?
Álvaro Touzón
@kasselTrankos
im blocked in the way that with a only one function affects to both values
fst and scnd
im still thinking if is able
and is the correct way of thinking
and if the way that is solved onto Pair must be solved on a Tuple
when aTuple both arguments are used with map
Álvaro Touzón
@kasselTrankos
by now, i think that even using tuple, i can only work with the second argument
like Pair
thats correct?
David Chambers
@davidchambers
That's right. t a has only one inner type.
Álvaro Touzón
@kasselTrankos
yes, im mading some cases of use
and only affects to second argument