`(>>=)` should be constrained with `Map`
See original GitHub issueHello,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:
- Created a year ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cannorin I know haskell, purescript, etc
Then you would need to accept that:
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.