These are chat archives for ramda/ramda

12th
Mar 2017
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 01:50
do you have any function that takes an array of a single element and returns just the element?
like [a] -> a
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 01:53
R.head
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 01:54
@Alexis-De-La-Torre I think that will do exactly as you say
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 01:57
that works, it was there all the time and i didnt see it xD
is there someting like that but with functors like maybe, something that would do Just a -> a
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:02
Not a generic function, no. Being a Functor (or Monad for that matter) doesn't guarantee any sort of extracting method
Most of the libraries that provide Maybe will provide such a function... no standard name for it though
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:04
oh, that was what i was looking for, a standard name
do you use ramda-fantasy?
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:06
No. I use Folktale or Sanctuary and Fluture
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:09
ok, on sanctuary whats the name of that function?
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:10
fromMaybe is the function
And I don't think there's a public method on the objects...
Folktale has get and getOrElse I think...
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:12
but i can map it, cant i?
Just(a).map(fromMaybe)
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:12
Oh yeah, for sure
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:12
that would give me the a
that works for me, thanks
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:13
Well, wait a sec...
You would just do
fromMaybe(default, maybeObj)
Then you'd get the innards or the default
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:14
so default in case is Nothing?
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:15
Exactly
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:15
thats great, this fp stuff is making sense now ;p
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:15
Awesome
:-)
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:17
just a side question
i am stalking your github and found this https://github.com/Bradcomp/testing-talk
is there a video of this talk, looks interesting
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:18
Heh, I'm actually not sure, but I don't think so.
It was at a JS meetup and I don't think they filmed it
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:21
thats a bummer, were i live there is not a developer community so i like to watch talks as if i was there xD
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:24
Sorry :(
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 02:27
no prob, why do you prefer sanctuary + fluture over r-f?
Brad Compton (he/him)
@Bradcomp
Mar 12 2017 02:28
I like Sanctuary because of the runtime type system
Matthew Willhite
@miwillhite
Mar 12 2017 02:49

@rjhilgefort It sounds like you are looking for a thunk…in which case if you want to delay the execution of foo then AFAIK you have two one options:

  1. Wrap it in a function block .then(() => foo(arg1, arg2, arg3));
  2. Hack it with curry :smiling_imp: .then(curryN(4, foo)(arg1, arg2, arg3))

I’d recommend the former…

@Alexis-De-La-Torre Where do you live? I’m also in a location with a limited developer community…
Alexis De La Torre
@Alexis-De-La-Torre
Mar 12 2017 04:28
I live in Mexico, a city called Ensenada especifically. Is getting there i think but for now you have to go to other places for this kind of thing
Drew
@dtipson
Mar 12 2017 12:47
S.head
Johnny Hauser
@m59peacemaker
Mar 12 2017 23:58

Given that this is lame:

cond([
  is(String), foo),
  is(Object), bar),
  is(Array), baz)
])

What are good approaches/libraries for having better types in JavaScript?

The problem there being that is(Object, []) === true