Quantcast
Channel: User Tarmil - Stack Overflow
Browsing all 38 articles
Browse latest View live
↧

Comment by Tarmil on Why is it so slow to create records with a field that...

The thing is, for Set, you need not just equality but comparison. And you can't really do comparison by reference in .NET. So I think you have 2 choices. 1: Add a Guid to BigType, fill it with...

View Article


Comment by Tarmil on Catching inner exception in F# async block

You can't use reraise in an async though. But come to think of it, you can also just skip this branch and it will be reraised by async.

View Article

Comment by Tarmil on How to use FSharp.Data.JsonProvider dynamically?

@JoshDredge Edited the answer for this case.

View Article

Comment by Tarmil on Implementing let! ... and! ... in a custom Computation...

Unfortunately the link to the RFC is dead in the announcement blog; here is the correct address: github.com/fsharp/fslang-design/blob/main/FSharp-5.0/…

View Article

Comment by Tarmil on F# How to use an anonymous type in place of a full typed...

I think you're looking for an equivalent of C#'s new(15000f) aka target-typed new expressions? There isn't one in F#.

View Article


Comment by Tarmil on Value option for optional parameters in F#?

@sdgfsdh Yes, this parameter will also be treated as optional by an F# caller.

View Article

Comment by Tarmil on F# script can't find nuget package - probably because...

You can specify a source in the script with #i "nuget: https://...". But I don't think it completely overrides the ones in your global config, it just adds one.

View Article

Comment by Tarmil on How to Parse a DateTime in a specific timezone in .Net 6...

@MrDatKookerellaLtd In GetUtcOffset, the unspecified date is interpreted as a datetime in the Sydney timezone.

View Article


Comment by Tarmil on F#: How can I wrap a non-async value in Async

"in your use case it won't work, due to eager evaluation of the argument." On the contrary, it would be a closer equivalent of Task.FromResult, which is also eager.

View Article


Comment by Tarmil on Why does module rec result in a warning?

@sdgfsdh Yes, it can be determined statically. I guess the point of not doing it is to discourage the use of module rec as a way to just reorder declarations that are not actually mutually recursive.

View Article

Comment by Tarmil on Type method appears to call private functions in an...

In fact, seq<T> isn't just implemented via IEnumerable<T>; it's a simple alias for IEnumerable<T>.

View Article

Comment by Tarmil on Unexpected result with F# type check

Yeah, the fact that null doesn't match :? obj is expected, but the compiler definitely shouldn't warn that it always does!

View Article

Comment by Tarmil on How to make anchors work when switching between two...

It's in Bolero, you need to open Bolero.Remoting.Client. (and I should move it to Bolero, it would be better there)

View Article


Answer by Tarmil for How do you declare a type alias in a f# constructor?

You can't put a type declaration inside another. What you can do is make mutually recursive type declarations:type Entity = abstract member newEntity: T abstract member clearEntity : T abstract member...

View Article

Answer by Tarmil for F# query expression: How to do a left join and return on...

I think this should do the trick:query { for student in db.Student do leftOuterJoin selection in db.CourseSelection on (student.StudentID = selection.StudentID) into result where (not (result.Any()))...

View Article


Answer by Tarmil for F# query expression nested lists

What you're doing is pretty much exactly what groupJoin does.let events = query { for event in db.Events do groupJoin ea in db.EventAttendances on (event.Id = ea.EventId) into result select (event,...

View Article

Answer by Tarmil for Can't get bind operator to work with discriminated union

When you use an operator, F# looks for it in order:as a let-defined operator;as a static member-defined operator on one of the two arguments' types. Here, the arguments you are passing to the operator...

View Article


Answer by Tarmil for Generating custom data in FsCheck

To always generate valid Quality and ShelfLife, you need to register Arbitrary instances:type Arbs = static member Quality() = Arb.Default.NonNegativeInt() |> Arb.convert (fun (NonNegativeInt x)...

View Article

Answer by Tarmil for F# unit of measure to model area

There are several things here:You need to define area as being a square length with type area = radius * radius. Otherwise the compiler has no way to match your input and output units.Pi, when used...

View Article

Answer by Tarmil for F# Discriminated Union - "downcasting" to subtype

This is a common mistake when coming from an OO language: there are no subtypes involved in this code. The fact that you named your union cases the same as the type of the field they contain can make...

View Article
Browsing all 38 articles
Browse latest View live




<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>