Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Patrik Andersson
@pandemonium
But that really helped me! I was not paying attention to the type signature of put
So thank you :)
Gustavo Leon
@gusty
@pandemonium here's my exploration on type defunctionalization applied to this library #401
I tried compiling the example of that S.O. question, without applying the tricks I suggested, and it works like a charm
Patrik Andersson
@pandemonium
Awesome - will have to look a little later today :)
Gustavo Leon
@gusty
take your time, it's proably long to digest
in this chat history there were also some edge cases sample code, posted by other users, we could test them with this technique
and btw: here yes, you could simply replace ReaderT with StateT and boom, now you have an updatable state ;)
Patrik Andersson
@pandemonium
This is so cool I almost feel like canceling my plans to play around instead :D
Patrik Andersson
@pandemonium
Something else: do you guys know of a decent typeclass emulation mechanism?
Gustavo Leon
@gusty
@pandemonium the best typeclass emulation mechanism available in F# is SRTPs
that's the closest I can think of, and of course, used the way it's in this library. The blog I linked you should give you a good starting point.
Patrik Andersson
@pandemonium
Yeah, saw that like 5 minutes after I asked :)
Patrik Andersson
@pandemonium
@gusty it is hard to get to a point where you can have real ad hoc polymorphism though
Because I don't seem to be able to add more static operator overloads in another module
Gustavo Leon
@gusty
@pandemonium you mean to a type where you don't control the source?
Patrik Andersson
@pandemonium
I guess I could use a type constraint
pangwa
@pangwa
merry x'mas!
it looks like traverse is not lazy enough... Is it possible to fix it?
let mapper v = 
    Console.WriteLine (sprintf "mapping %d " v)
    if v > 3 then Result.Error(sprintf "error: %d" v)
    else Result.Ok v

let testTrav l = 
    let v = Seq.traverse mapper l 
    v |> Result.map Seq.last

let r = Seq.ofList [1; 2; 3; 4; 5] |> testTrav
match r with
| Result.Ok v -> Console.WriteLine (sprintf "got %d" v)
| Result.Error err -> Console.WriteLine (sprintf "failed %s" err)

prints

mapping 1
mapping 2
mapping 3
mapping 4
mapping 5
failed error: 4

Gustavo Leon
@gusty
@pangwa I think this is by design
It stops but needs to do one more iteration before stopping
Gustavo Leon
@gusty
I mean, if we looks at the tests, that's the expected behavior
I'm trying to remember why
Gustavo Leon
@gusty
and I'm failing to remember why was that the expectation
would solve the issues, since the e.MoveNext () is what calls the map on the sequence
Gustavo Leon
@gusty
Ok, this is definitely not by design and indeed a genuine issue.
My confusion was that the tests were checking the applicative call, but they are not checking it at the mapping function call.
The solution is, as I said to swap the order of the operands and add a test check for the mapping function.
I will write this in the issue you opened, thanks !
pangwa
@pangwa
Cool, thanks, I assumed they're working the same way as traverse in haskell. And it surprised me yesterday ;-)
Onur Gumus
@OnurGumus
Does FSharp+ run in fable?
Oskar Gewalli
@wallymathieu
Yes it does. There are some limitations. More of F#+ works in Fable3 though
fsprojects/FSharpPlus#392
Patrik Andersson
@pandemonium
Good morning dear F#+ :)
So I was wondering if you were working on an STM implementation or knew about one?
padzikm
@padzikm
Hi, do you plan to add stack safe version of free monad? current implementation of free's run and fold aren't stack safe. In scala's cats there is foldMap implemented via trampoline, which I didn't find in f#+ repo
Gustavo Leon
@gusty
@padzikm already answered in the issue
@pandemonium sorry for the late reply
I am not sure how useful would be the STM monad in F#
I'm under the impression that is a Haskell trick to overcome their limitations imposed by the fact of being a pure language
I think F#x had an implementation
Anyways, if you feel like it can be useful in some specific scenarios please open an issue and we can discuss it.
Patrik Andersson
@pandemonium
There's no trick involved, it's merely a monadic way to compose transactions over refs
I think it would be an interesting way to implement DDD aggregates in an event sourced world without resorting to an actor model
Patrik Andersson
@pandemonium
I seem unable to get >=> to work between two Kleisli values
Is >=> applicable to Kleisli<_, 'a M> and Kleisli<'a, 'b M> ?
Oskar Gewalli
@wallymathieu
Implementing DDD aggregates in an event sourced world without actor model sounds interesting.
Gustavo Leon
@gusty
@pandemonium >=> should normally work. If it doesn't can you post a repro or an issue ?