Skip to content

Function Composition #936

Answered by duvenaud
pharringtonp19 asked this question in Q&A
Jun 3, 2022 · 3 comments · 8 replies
Discussion options

You must be logged in to vote

Oh, I think that's a bug / limitation of the current type system. At least, I think it's the same as issue #867. I think the problem is that there are multiple possible floating point types, and when you write m = compose sin cos, the compiler isn't sure which one you want, and can't automatically build an m that's polymorphic in a.

You can do what you want by telling Dex which kind of number you want:

m : Float32 -> Float32 = compose sin cos
m 1.0
0.666367

This is annoying, although it usually isn't an issue when you're not at the top level, so it rarely comes up in practice for me.

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@pharringtonp19
Comment options

Comment options

You must be logged in to vote
2 replies
@pharringtonp19
Comment options

@apaszke
Comment options

Answer selected by pharringtonp19
Comment options

You must be logged in to vote
5 replies
@duvenaud
Comment options

@pharringtonp19
Comment options

@pharringtonp19
Comment options

@pharringtonp19
Comment options

@apaszke
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants