Example cases with 了
(A1)我学了六年法语了


The first 了 is an aspect marker, indicating completed action. the second 了 is final particle, indicating change of situation. It is not grammatically incorrect, but native Chinese would most likely skip using the final particle to avoid 了 appear in a short sentence twice.


  (A2)我学六年法语了


Without the aspect marker 了 to indicating completed action, 学六年法语 could be confusing... are you going to learn "six years of French?" or you going to learn " Sixth Year French?"


  (A3)我学了六年法语


This one fixes the problem (A2) has. A grammatically correct sentence


  (A4)我学六年法语


Just like (A2) is it "six years of French?" or " Sixth Year French?"


  (A5)我学了法语六年了


This one is similar to (A1) just the object 法语 and the relative phrase 六年 switched place. Again, the final particle can be omitted.


  (A6)我学法语六年了


Similar to (A3) with the object 法语 and the relative phrase 六年 switched place, also a grammatically correct sentence.


  (A7)我学了法语六年


Similar to (A5) with the final particle omitted, Which make it better structured sentence.


  (A8)我学法语六年


Without either the aspect marker 了 or the final particle 了, the sentence is unfinished. 


(A3) , (A6) and (A7) are the three grammatically correct and well structured sentences on the list.
(A1) and (A5) are not grammatically wrong, just not sounding smooth with two 了 in the same sentence
(A2) and (A4) are not grammatically wrong, but a little bit ambiguous with 六年法语 could mean either "six years of French" or " Sixth Year French"
(A8) is unfinished sentence



  (B1)我学法语


I learn French


  (B2)我学了法语


I learned French


  (B3)我学法语了


if 了 is treated as a aspect marker, the sentence would mean "I have learned French"

if 了 is treated as a final particle, the sentence would mean "I've started learning French"


  (B4)我学了法语了


I learned French (already)- like in Group A,  final particle 了 could be omitted

*Group C are all incomplete sentences.