Habeas Corpus1. Overview
2. Test for Habeas Corpus
3. Procedure for Habeas Corpus
4. Detention Need not be Incarceration
5. Exceptions to Habeas Corpus
6. Standard of Review
1. Overview. Wang v Canada
In Wang v. Canada (Ont CA, 2018) the court canvasses the history and purpose behind the writ of habeas corpus:
 I begin with the decision in May v. Ferndale Institution, 2005 SCC 82 (CanLII),  3 S.C.R. 809. While May involved a challenge by federal inmates to the reclassification of their security level within the federal penitentiary system, and was thus factually distinct from the situation here, the importance of the decision for current purposes lies in its review of the history and principles surrounding habeas corpus.
 The majority in May reviewed the purpose behind the writ of habeas corpus. Fish and LeBel JJ., at para. 21, quoted from a decision of Black J. in the United States Supreme Court where he said that the purpose of habeas corpus was “the protection of individuals against erosion of their right to be free from wrongful restraints upon their liberty”. That protection was stated in broad terms. It was not restricted to imprisonment but to any restraint on a person’s liberty. Such restraints can take many different forms.
 The decision in May went on to consider other cases that had touched on the purpose of habeas corpus. It referred to the Supreme Court of Canada’s trilogy of decisions in R. v. Miller, 1985 CanLII 22 (SCC),  2 S.C.R. 613; Cardinal v. Director of Kent Institution, 1985 CanLII 23 (SCC),  2 S.C.R. 643; Morin v. National Special Handling Review Committee, 1985 CanLII 24 (SCC),  2 S.C.R. 662. The court pointed out, at para. 31, that in Miller, Le Dain J. had also described habeas corpus as “the traditional means of challenging deprivations of liberty”. Again, there was no suggestion that the remedy was restricted to incarceration. The court then went on to consider the exceptions to the general right of an individual to resort to habeas corpus to challenge their detention, a subject to which I will return shortly.
 Lastly, the court reinforced the importance of the remedy of habeas corpus and the care which courts ought to take in making any determination that it was not available as a route to challenge restrictions on a person’s liberty. Fish and LeBel JJ. said, at para. 50:
Given the historical importance of habeas corpus in the protection of various liberty interests, jurisprudential developments limiting habeas corpus jurisdiction should be carefully evaluated and should not be allowed to expand unchecked. The exceptions to habeas corpus jurisdiction and the circumstances under which a superior court may decline jurisdiction should be well defined and limited.
2. Test for Habeas Corpus. Boone v Ontario (Community Safety and Correctional Services)
In Boone v Ontario (Community Safety and Correctional Services) (Ont CA, 2014) the court simply sets out the test for habeas corpus:
 To be successful, an applicant for habeas corpus must show (a) a deprivation of liberty and (b) that the deprivation of liberty was unlawful: ...
3. Procedure. Boone v Ontario (Community Safety and Correctional Services)
As to what the procedure is for habeas corpus, the court in Boone v Ontario (Community Safety and Correctional Services) (Ont CA, 2014) states:
 First, once a deprivation of liberty has been shown, and the applicant has raised a legitimate ground on which to question its validity, the onus shifts to the Crown to show that the deprivation was lawful. Secondly, where a deprivation of liberty has occurred, and a legitimate ground to question its validity has been raised, the hearing judge must proceed to a hearing; there is no discretion to do otherwise. Finally, the hearing judge retains a “residual discretion” at this second stage of the proceedings to decide, after reviewing the record, whether to discharge the applicant: see Khela, at paras. 30 and 78.. Wang v Canada
 It is true that habeas corpus is a remedy that issues as of right (ex debito justitiae) once the unlawful nature of the detention is established. It cannot be denied because another, equally effective remedy – such as judicial review – exists. That was the issue debated in May and Khela. As LeBel J. affirmed in Khela, however, the non-discretionary nature of the writ relates to whether the applicant has raised a legitimate basis for questioning the legality of the detention, not to the ultimate determination of whether, on the whole of the record, the unlawful nature of the detention is established. There remains a residual discretion in this regard. At paras. 77 and 78, he said:
First, the traditional onuses associated with the writ will remain unchanged. Once the inmate has demonstrated that there was a deprivation of liberty and casts doubt on the reasonableness of the deprivation, the onus shifts to the respondent authorities to prove that the transfer was reasonable in light of all the circumstances. Where there has been a denial of the right to a fair hearing, the administrative decision will always be unlawful. However, not all procedural breaches will necessarily result in procedural unfairness and the denial of the right to a fair hearing: see Khela, at para. 90; Canadian College of Business and Computers Inc. v. Ontario (Private Career Colleges Act, Superintendent), 2010 ONCA 856 (CanLII), 2010 ONCA 856, at paras. 65-67; and Uniboard Surfaces Inc. v. Kronotex Fussboden GmbH and Co. KG (F.C.A.), 2006 FCA 398 (CanLII), 2006 FCA 398,  4 F.C.R. 101, at para. 24.
Second, the writ remains non-discretionary as far as the decision to review the case is concerned. If the applicant raises a legitimate doubt as to the reasonableness of the detention, the provincial superior court judge is required to examine the substance of the decision and determine whether the evidence presented by the detaining authorities is reliable and supports their decision. Unlike the Federal Court in the context of an application for judicial review, a provincial superior court hearing a habeas corpus application has no inherent discretion to refuse to review the case (see Farbey, Sharpe and Atrill, at pp. 52-56). However, a residual discretion will come into play at the second stage of the habeas corpus proceeding, at which the judge, after reviewing the record, must decide whether to discharge the applicant.
In Wang v Canada (Ont CA, 2018) the court comments on procedure as follows:
 This conclusion is also consistent with the proper approach to be taken to habeas corpus applications. As pointed out in Mission Institution v. Khela, 2014 SCC 24 (CanLII),  1 S.C.R. 502 at para. 30, habeas corpus applications proceed in two stages. First, the applicant must show that he or she has been deprived of liberty and that there is a legitimate ground upon which to question the legality of the detention. If the applicant succeeds in meeting that threshold, the onus shifts to the authorities to show that the deprivation of liberty is lawful.
 It is the first stage that we are concerned with in this case. Importantly, the first stage is not described as requiring the applicant to be detained in custody, or to be incarcerated, or to be held in a custodial facility, or any other such language. The key to the first stage is simply, but crucially, a deprivation of liberty. ...
4. Detention Need not be Incarceration. Wang v Canada
In Wang v. Canada (Ont CA, 2018) the court states the 'detention' need not be situations of formal incarceration:
 In my view, the application judge erred in the above conclusion [whether there was no 'detention': ed.]. He did so in two related respects. One is that he equated detention for the purposes of habeas corpus with incarceration in a custodial facility. The other is that he appears to have restricted the operation of habeas corpus only to situations where a person is formally detained rather than to broader situations where liberty interests are infringed. Put more simply, the application judge wrongly concluded that in order for there to be an infringement of liberty, to which the writ of habeas corpus could apply, there had to be a detention of the individual in a custodial facility. That view does not find support in the case law nor does it accord with the fundamental constitutional values that underlie the important remedy reflected in the principle of habeas corpus. ....
 Admittedly, the most common use of the writ of habeas corpus is where a person is being held in custody and they have not, for whatever reason, been granted a hearing respecting their qualification for release from custody. But there is nothing in the history of the remedy that would justify limiting its reach solely to situations where a person is being held in custody. The most common use should neither eclipse nor exclude other possible uses.
 The core protection afforded by the writ of habeas corpus is the protection of a person’s liberty. That is, the protection of the right that every individual has to go about their daily life without interference by the state. Where the state acts to restrict the liberty of the individual, then the individual must have the right to seek a review of the legitimacy of those restrictions. As Rouleau J.A. said in Chaudhary, at para. 94:
Habeas corpus issues as of right once a detainee proves a deprivation of liberty and raises a legitimate ground upon which to question the legality of that deprivation. (Emphasis added).....
 As the decision in May makes clear, habeas corpus potentially applies to any situation where the state restrains the liberty of the subject. A person subject to house arrest is a person who has had their liberty restricted. They are unable to do that which every other ordinary citizen is entitled to do. As Sharpe J.A. aptly put it in his dissenting reasons in R. v. Panday, 2007 ONCA 598 (CanLII), 87 O.R. (3d) 1, at para. 63:
Bail and jail are different points on a continuum between complete freedom and total deprivation of liberty. Strict conditions amounting to house arrest significantly constrain liberty and push bail towards the total deprivation of liberty end of the continuum.See also R. v. Downes (2006), 2006 CanLII 3957 (ON CA), 79 O.R. (3d) 321 (C.A.), at para. 29.
 A further decision of importance to this issue is R. v. Gamble, 1988 CanLII 15 (SCC),  2 S.C.R. 595, where the writ of habeas corpus was used to challenge a parole ineligibility provision. Parole, of course, takes effect after a person is released from custody. In commenting on the flexibility that is important to the remedy, especially in the context of Charter rights, Wilson J. said, at para. 64:
There is no doubt that considerable uncertainty has clouded the scope of review open to a court on an application for habeas corpus and it is understandable that courts have, in general, not bound themselves to limited categories or definitions of jurisdictional review when the liberty of the subject was at stake. [Citations omitted.]
5. Exceptions to Habeas Corpus. Wang v Canada
In Wang v. Canada (Ont CA, 2018) the court states exceptions to the application of the common law writ of habeas corpus:
 As referenced in May, there are two exceptions to the availability of habeas corpus. One is where a statute confers jurisdiction on a court of appeal to correct the errors of a lower court and to release the affected person, if necessary. The other is where a legislator has put in place a complete, comprehensive and expert procedure for review of an administrative decision affecting a person’s liberty.
6. Standard of Review. Wang v Canada
In Wang v. Canada (Ont CA, 2018) the court notes that the standard of judicial review is one of 'correctness'. In judicial review cases the law distinguishes 'correctness' from 'reasonableness', the latter being more forgiving of the tribunal below and the former requiring that the decision below be simply 'correct'.
 Before embarking on that review, however, I would point out that the scope of the writ of habeas corpus constitutes a question of law. The standard of review is, thus, one of correctness: Housen v. Nikolaisen, 2002 SCC 33 (CanLII),  2 S.C.R. 235, at para. 8.-----------------------------
Forster v. Canada (Correctional Service) (Ont CA, 2019)