Behavior of F# "unmanaged" type constraint

Behavior of F# "unmanaged" type constraint

By : Bucur Radu
Date : November 17 2020, 01:00 AM
will be helpful for those in need I've got some feedback, beware that I don't know F# nearly well enough. Please edit where I goof. Getting to the basics first, the runtime does not actually implement the constraints that F# supports. And supports more than what C# supports. It has just 4 types of constraints:
must be a reference type (class constraint in C#, not struct in F#) must be a value type (struct constraint in C# and F#) must have a default constructor (new() constraint in C#, new in F#) constrained by type.
code :
namespace FSharpLibrary

type FSharpType<'T when 'T : unmanaged>() =
    class end
class Program {
    static void Main(string[] args) {
        var obj = new Example();   // fine
class Foo { }
class Example : FSharpLibrary.FSharpType<Foo> { }

Share : facebook icon twitter icon
Unusual behavior of facebook grap API ("type": "GraphMethodException", "code": 100)

Unusual behavior of facebook grap API ("type": "GraphMethodException", "code": 100)

By : J.Cool.K
Date : March 29 2020, 07:55 AM
To fix this issue This isn't a bug, the error means that the data you're trying to access is not accessible to you, does not exist, has been deleted, is not available because you haven't provided an access token from a user who can see it, etc.
See this answer for an example of this error message in relation to Facebook pages: https://stackoverflow.com/a/6847088/21062 - the same is true when trying to access user profiles if that user has blocked you, blocked your app, disabled their account or disabled all apps from accessing their information.
"unmanaged" generic parameter constraint in IL

"unmanaged" generic parameter constraint in IL

By : kadalbonek
Date : March 29 2020, 07:55 AM
may help you . These constraint are located in the entity data stored in FSharpSignatureData managed resource. It is possible to browse them using F# Metadata Reader from F# PowerPack:
code :
public static IList<FSharpGenericParameterConstraint> GetFSharpGenericParameterConstraints(Type genericType, int position)
    return GetFSharpGenericParameterConstraints(genericType.GetGenericArguments()[position]);

public static IList<FSharpGenericParameterConstraint> GetFSharpGenericParameterConstraints(Type genericParameter)
    var declMethod = genericParameter.DeclaringMethod;
    var declType = genericParameter.DeclaringType;
    var fsAsm = FSharpAssembly.FromAssembly(genericParameter.Assembly);
    int pos = genericParameter.GenericParameterPosition;
    var entities = AllEntities(fsAsm.Entities);
    if(declMethod != null)
        var member = entities.SelectMany(e => e.MembersOrValues).First(m => m.ReflectionMemberInfo == declMethod);
        return member.GenericParameters[pos].Constraints;
    }else if(declType != null)
        var entity = entities.First(e => e.ReflectionType == declType);
        return entity.GenericParameters[pos].Constraints;
    return null;

private static IEnumerable<FSharpEntity> AllEntities(IEnumerable<FSharpEntity> entities)
    return entities.Concat(entities.SelectMany(e => AllEntities(e.NestedEntities)));
bool unmanaged = GetFSharpGenericParameterConstraints(typeof(MyModule.Class1<>), 0).Any(c => c.IsUnmanagedConstraint);
Symfony "Type" constraint: Expected argument of type "string", "array" given exception

Symfony "Type" constraint: Expected argument of type "string", "array" given exception

By : Anoop
Date : March 29 2020, 07:55 AM
help you fix your problem Only solution I've found was to create event listener which simply converts exception to beauty error (it's okay for me because I'm developing API only, not full stack).
Simplified part of my exception event listener:
code :
namespace AppBundle\EventListener;

use AppBundle\Exceptions\FormValidationException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\Validator\Exception\ValidatorException;

class ApiExceptionListener
     * @var bool
    public $isKernelDebug;

    public function __construct(bool $isKernelDebug)
        $this->isKernelDebug = $isKernelDebug;

    public function onKernelException(GetResponseForExceptionEvent $event)
        $throwedException = $event->getException();

        $errorBody = [
            'code'    => $throwedException->getCode(),
            'message' => $throwedException->getMessage(),

        if ($throwedException instanceof ValidatorException) {
            $errorBody['message'] = 'Invalid data has been sent';

        if ($this->isKernelDebug) {
            $errorBody['exception'] = [
                'class'   => get_class($throwedException),
                'message' => $throwedException->getMessage(),
                'code'    => $throwedException->getCode(),

        $event->setResponse(new JsonResponse(['error' => $errorBody]));
    class: AppBundle\EventListener\ApiExceptionListener
    arguments: ['%%kernel.debug%%']
        - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }
Strange behavior of type parameters in "type" versus "newtype": is this a bug or a feature?

Strange behavior of type parameters in "type" versus "newtype": is this a bug or a feature?

By : newbie
Date : March 29 2020, 07:55 AM
Hope this helps Why this fails for a type...
If you write type then you do not construct a new type, you construct an alias. So you defined:
code :
type VarName a = Text
reflectiveNames :: Reflective a => [Text]
reflectiveNames = map reflectiveName reflectiveDefaults
newtype VarName a = VarName Text
data VarName a = VarName Text
reflectiveNames :: Reflective a => [VarName a]
reflectiveNames = map reflectiveName reflectiveDefaults
type Foo = VarName Char   -- a ~ Char
type Bar b = VarName Int  -- a ~ Int
Why "int/boolean/..." are primary types which have no "behavior" where type is "behavior specif

Why "int/boolean/..." are primary types which have no "behavior" where type is "behavior specif

By : Ahmad Winchester
Date : March 29 2020, 07:55 AM
To fix this issue Primitive types and Null types are "types" because the JLS specifies them as such. The JLS does not provide a formal definition of "type" other than that there are three types a ReferenceType, a PrimitiveType, and null type [JLS 4.1].
It is likely the second paper linked is reusing the terms defined in the JLS.
Related Posts Related Posts :
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • How to discover that appsettings changed in C#?
  • Check what needs full trust
  • What is the execution order of an MVC Razor view/layout
  • Table designer (Entity Framework) is too resource intense
  • How to clean up an exception string so it can be displayed via Javascript Alert?
  • Configuring Amazon SES Feedback Notifications via Amazon SNS in ASP.NET MVC (C#)
  • C# api responce and request
  • Dynamodb putitem function not working properly
  • theme in windows phone(light or dark) using c#
  • Backup attached database file(.mdf) using c# and SQL Server
  • What is 'TextFile' and where it is uses in WPF project
  • Using same alias for multiple namespaces
  • how to move mails into separate folders
  • Multithreaded Uploader
  • Memory fragmentation?
  • C# correct exception handling
  • "Could not open macro storage" when accessing using file on another machine
  • How to access other directories of hosted server
  • C# Jagged Array check if value exists/true
  • Why can't I type Clone() properly?
  • exception on accessing dictionary from list
  • Getting the immediate response from server without waiting to 200 message
  • Why am I getting exception Directory Is Not empty?
  • Could not load file or assembly 'CefSharp.dll' or one of its dependencies
  • Sending Email By Using C# in unity3D?
  • Correct usage of await async in webapi
  • Program update code issue
  • Marshal.Copy attempted to read or write protected memory At Random Times
  • Restrict Type variable to specific class or subclass
  • Horizontal text alignment in a PdfPCell
  • C# crashing with Form.show() command, ObjectDisposedException - Deeper look / explanation please
  • Will the result of a LINQ query always be guaranteed to be in the correct order?
  • "Could not find default endpoint element that references contract"
  • Umbraco Request.QueryString is null if it's the first time the page is loaded
  • Error inconsistent accessibility method C#
  • How to program Intel Xeon Phi with C#?
  • remove nested element using regular expression
  • Is there a C# alternative to Java's vararg parameters?
  • Clear particular column values in DataTable
  • how to add event handler to programatically created checkboxes
  • Cannot apply indexing with [] to an expression of type 'System.Collections.Specialized.NameValueCollection'
  • Check for key in pre-existing dictionary in case insensitive manner
  • How to remove year from datetime object?
  • Accessing Settings in different ways
  • "This project is empty" error in Sonarqube
  • How to create reusable icon menu in Xamarin
  • Value Cannot be null in Ado.Net connectivity
  • Adding a custom/dynamic attribute when using XSD.exe
  • How to convert object to correct type
  • Automatically sign out from Forms Authentication in ASP.NET when browser is closed
  • Can a WCF service support both Buffered and Streamed transfer modes?
  • Verify a CA Certificate with a public key in C#
  • How to invoke a Web Service that requires the "patch" verb using the C# WebClient wrapper?
  • Proper way a implementing property based on generic type
  • Closing a form that is created in another thread
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org