27 May 2023 |
n.daniel | I wonder | 18:46:53 |
n.daniel | Why do we model ML models in Python | 18:47:08 |
n.daniel | I'd imagine something functional would be a better fit | 18:47:21 |
n.daniel | A graphic for >>= of the state monad really reminded me of stateful ML | 18:48:20 |
n.daniel | Transformers, I think | 18:48:37 |
Heffalump | In reply to @21it:matrix.org I'm just playing around. Always was curious how this magic does work. Just as simple example I want to build a transpiler from Haskell (just simple Haskell, small subset) into Gleam, which is a simple typed language with very minimalistic syntax. If you want the end result to be readable code you'd be best off starting with the source AST | 19:35:34 |
ic.rbow | In reply to @n.daniel:matrix.org A graphic for >>= of the state monad really reminded me of stateful ML You don't need state to build a network. It just a bunch of functions, really. | 19:36:47 |
ic.rbow | There are a few implementations. Native and TF. | 19:37:02 |
n.daniel | In reply to @ic.rbow:matrix.org You don't need state to build a network. It just a bunch of functions, really. For recurrent networks you do afaik | 19:37:05 |
n.daniel | At the very least the transformers with their hidden state remind me of the state monad | 19:37:22 |
ic.rbow | https://hackage.haskell.org/package/grenade | 19:38:03 |
n.daniel | That's quite neat, thanks for the link | 19:38:29 |
n.daniel | Looking at the code, it looks intimitating | 19:41:04 |
n.daniel | But on closer look, I don't think its that bad | 19:41:14 |
n.daniel | Probably a combination of being used to imperative programming and Python hiding the types | 19:41:40 |
@21it:matrix.org | In reply to @n.daniel:matrix.org Looking at the code, it looks intimitating There is a lot of advanced type-level stuff in this library. It's not bad, but in my experience (from working with a bit less experienced haskellers in a team) singletons and dependent types are the things which you will start to appreciate only when you hit the limitations of the standard (Haskell 98 or Haskell 2010) "boring" type systems. In all the other cases coerce goes brrrr. | 20:11:09 |
@21it:matrix.org | How wide is the code compexity range (from "boring" to "advanced") in Haskell is really impressive (comparing with simpler languages like Erlang). | 20:15:47 |
scholablade |
I would if someone would explain this:
Here is an expression:
```
head ’ :: [ a ] -> a
head ’ [] = error " Can ’ t call head on an empty list , dummy ! "
head ’ ( x : _ ) = x
```
Calling the function:
```
ghci > head ’ [4 ,5 ,6]
4
```
Considering that we only pattern matched for (x: _), rather than (x: _: _), why aren't we getting an error? | 22:23:28 |
scholablade | * I would if someone would explain this: Here is an expression:
head ’ :: \[ a \] -> a
head ’ \[\] = error " Can ’ t call head on an empty list , dummy ! "
head ’ ( x : \_ ) = x
Calling the function: ``` ghci > head ’ [4 ,5 ,6] 4 ``` Considering that we only pattern matched for (x: _), rather than (x: _: _), why aren't we getting an error?
| 22:24:06 |
scholablade | * I would if someone would explain this: Here is an expression:
head ’ :: \[ a \] -> a
head ’ \[\] = error " Can ’ t call head on an empty list , dummy ! "
head ’ ( x : \_ ) = x
Calling the function:
ghci > head ’ \[4 ,5 ,6\]
4
Considering that we only pattern matched for (x: _), rather than (x: _: _), why aren't we getting an error?
| 22:24:17 |
scholablade | * I would if someone would explain this: Here is an expression:
head ’ :: [ a ] -> a
head ’ [] = error " Can ’ t call head on an empty list , dummy ! "
head ’ ( x : _ ) = x
Calling the function:
ghci > head ’ [4 ,5 ,6]
4
Considering that we only pattern matched for (x: _), rather than (x: _: _), why aren't we getting an error?
| 22:24:48 |
geekosaur | because the list matched is (4 : [5,6]) | 22:25:04 |
scholablade | What do you mean?
It's [4, 5, 6] | 22:25:54 |
geekosaur | or if you prefer, (4 : (5 : (6 : []))) | 22:26:08 |
geekosaur | the [] form is a convenience; the actual format of a list is (head : tail) where tail is the rest of the list | 22:27:12 |
geekosaur | so [4,5,6] is (4 : [5,6]) is (4 : (5 : (6 : []))) | 22:27:58 |
scholablade | Makes sense, i appreciate the help! | 22:28:19 |
scholablade | * I wish someone would explain this: Here is an expression:
head ’ :: [ a ] -> a
head ’ [] = error " Can ’ t call head on an empty list , dummy ! "
head ’ ( x : _ ) = x
Calling the function:
ghci > head ’ [4 ,5 ,6]
4
Considering that we only pattern matched for (x: _), rather than (x: _: _), why aren't we getting an error?
| 22:36:04 |
sm | https://haskell.foundation/hs-opt-handbook.github.io , now transferred to the Haskell Foundation.. awesome | 23:19:52 |
sm | * https://haskell.foundation/hs-opt-handbook.github.io from IOG, and now transferred to the Haskell Foundation.. awesome | 23:20:18 |