question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`(>>=)` should be constrained with `Map`

See original GitHub issue

Hello,Monad should be restricted with Map

Here

type Maybe<'a> =
   | Just of 'a
   | Nothing 

let maybeMap f m = match m with
  | Just x -> Just (f x)
  | Nothing -> Nothing

//type Maybe<'a> with
//  static member Map (x: Maybe<'a>, f: 'a -> 'b) = maybeMap f x

//let r2' = map (fun x -> x + 1.0) (Just 10.0)

let maybeBind f m = match m with
  | Just x -> f x
  | Nothing -> Nothing

type Maybe<'a> with
  static member (>>=) (x: Maybe<'a>, f: 'a -> Maybe<'b>) = maybeBind f x

let r2'' = Just 10 >>= fun x -> Just (x + 10)

Should throw error that, Maybe doesn’t have property Map, because Monad should be restricted with Map But probably should be Functor <= Applicative <= Monad

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
xgrommxcommented, Sep 10, 2022

@cannorin I know haskell, purescript, etc

0reactions
cannorincommented, Sep 10, 2022

Then you would need to accept that:

  • F# is not a language that comes with a first-class support of type classes.
  • FSharpPlus is not a language extension, and only provides an “emulated” version of type classes.
  • Therefore, the user experience on FSharpPlus’s type classes may not be as good as that of Haskell of PureScript.

I’m closing this issue because I don’t think this leads to a constructive discussion. I repeat my last message: if having type classes as a first-class language feature (i.e. more strict instance checks, more natural error messages, etc) is your priority, I guess you should better use some other languages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Go generics: type constraint for map keys?
The predeclared comparable constraint is the correct constraint for map keys, however it can be instantiated only by strictly comparable types, ...
Read more >
Generic constraint for maps : r/golang
I have a struct that multiplexes protobuf messages to callbacks and it's growing for each new type that we add.
Read more >
map() - Arduino Reference
Does not constrain values to within the range, because out-of-range ... The map() function uses integer math so will not generate fractions, ...
Read more >
Type Constraints - Configuration Language | Terraform
Learn how to use type constraints to validate user inputs to modules and resources. ... Maps can be made with braces ({}) and...
Read more >
all map elements must have the same type · Issue #21384 · ...
In my example, all elements of variable do have the same type which is map (map of maps). The actual correct constraint for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found